ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-10-29 07:48:21
Exec Total Coverage
Lines: 9415 12217 77.1%
Functions: 393 441 89.1%
Branches: 7495 12923 58.0%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1161175 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1161175 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1160898 times.
1161175 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1160898 times.
1160898 if (c < 0)
56 c -= val / 2;
57 1160898 else c += (val/2);
58 1160898 }
59 1161175 c -= c % val;
60 1161175 coord = c;
61 1161175 }
62
63 39573070 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 39056464 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 39571855 times.
39573070 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 39541535 times.
39571855 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39541535 times.
39541535 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 39541454 times.
39541535 if (x > world_w+256) return true;
69 39541454 return false;
70 39573070 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 435 void identifyCFEnemies()
108 {
109 435 trapConstantHorizontalID=-1;
110 435 trapConstantVerticalID=-1;
111 435 trapLOSHorizontalID=-1;
112 435 trapLOSVerticalID=-1;
113 435 trapLOS4WayID=-1;
114 435 cornerTrapID=-1;
115 435 centerTrapID=-1;
116 435 rockID=-1;
117 435 zoraID=-1;
118 435 statueID=-1;
119
120
2/2
✓ Branch 0 taken 222720 times.
✓ Branch 1 taken 435 times.
223155 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 222290 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 430 times.
222720 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 430 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 222279 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 435 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 435 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 435 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 435 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 435 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 435 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 222285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 435 rockID=i;
140
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 222244 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 432 times.
222720 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 432 zoraID=i;
142
143
4/4
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 222168 times.
✓ Branch 2 taken 117 times.
✓ Branch 3 taken 435 times.
222720 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 435 statueID=i;
145 222720 }
146 435 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 823532 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 613233 times.
✓ Branch 1 taken 210299 times.
823532 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4170490 bool enemy::overpit() const
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 38357256 times.
✓ Branch 1 taken 4142742 times.
42499998 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 27748 times.
✓ Branch 1 taken 38329508 times.
38357256 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 27748 return true;
254 }
255 38329508 }
256 }
257 4142742 return false;
258 4170490 }
259
260 2738192 bool enemy::shadow_overpit() const
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 33489077 times.
✓ Branch 1 taken 2716587 times.
36205664 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 21605 times.
✓ Branch 1 taken 33467472 times.
33489077 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 21605 return true;
271 }
272 33467472 }
273 }
274 2716587 return false;
275 2738192 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 9645414 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9645414 times.
9645414 if(moveflags & move_ignore_blockflags) return false;
281 9645414 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 6357351 times.
✓ Branch 1 taken 3288063 times.
✓ Branch 2 taken 1472123 times.
✓ Branch 3 taken 1815940 times.
12933477 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
6/6
✓ Branch 0 taken 3263934 times.
✓ Branch 1 taken 6381480 times.
✓ Branch 2 taken 408602 times.
✓ Branch 3 taken 2855332 times.
✓ Branch 4 taken 28668 times.
✓ Branch 5 taken 379934 times.
9645414 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 3379441 times.
✓ Branch 1 taken 6265973 times.
✓ Branch 2 taken 3377564 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 3377564 times.
✗ Branch 5 not taken.
19291592 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 3377564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3377564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3139583 times.
✓ Branch 5 taken 237981 times.
3377564 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 3372288 times.
✓ Branch 1 taken 3134307 times.
237981 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 3360260 times.
✓ Branch 1 taken 12028 times.
✓ Branch 2 taken 3360013 times.
✓ Branch 3 taken 247 times.
3372288 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 3357316 times.
✓ Branch 1 taken 2697 times.
✓ Branch 2 taken 3357250 times.
✓ Branch 3 taken 66 times.
3360013 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 54223 times.
✓ Branch 1 taken 3303027 times.
✓ Branch 2 taken 53928 times.
✓ Branch 3 taken 295 times.
6714205 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 1274561 times.
✓ Branch 1 taken 2082394 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 1272229 times.
3356955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 3382082 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 9073786 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9073786 times.
9073786 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6934805 times.
✓ Branch 1 taken 2138981 times.
✓ Branch 2 taken 1750538 times.
✓ Branch 3 taken 388443 times.
11212767 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
4/4
✓ Branch 0 taken 6949352 times.
✓ Branch 1 taken 2124434 times.
✓ Branch 2 taken 2097157 times.
✓ Branch 3 taken 27277 times.
11198220 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1265400 times.
✓ Branch 1 taken 7808386 times.
16882172 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7797980 times.
✓ Branch 1 taken 10406 times.
7808386 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7797861 times.
✓ Branch 1 taken 119 times.
7797980 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7790050 times.
✓ Branch 1 taken 7811 times.
7797861 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7789795 times.
✓ Branch 1 taken 255 times.
7790050 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6547266 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
15575586 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6537677 times.
✓ Branch 1 taken 1248114 times.
7785791 (pit_blocks && ispitfall(dx,dy))));
309 9073786 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 287854 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 287854 int32_t c = COMBOTYPE(dx,dy);
314 287854 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35642 times.
✓ Branch 1 taken 252212 times.
287854 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 287834 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 287717 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 287717 times.
✗ Branch 5 not taken.
1085745 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 287717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 287717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 255757 times.
✓ Branch 5 taken 31960 times.
287717 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 287047 times.
✓ Branch 1 taken 255087 times.
31960 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 285788 times.
✓ Branch 1 taken 1259 times.
✓ Branch 2 taken 285757 times.
✓ Branch 3 taken 31 times.
287047 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 281591 times.
✓ Branch 1 taken 4166 times.
✓ Branch 2 taken 281316 times.
✓ Branch 3 taken 275 times.
285757 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 279503 times.
✓ Branch 2 taken 1774 times.
✓ Branch 3 taken 39 times.
562593 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 57405 times.
✓ Branch 1 taken 223872 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 28870 times.
281277 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 144461 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 142138 times.
✓ Branch 1 taken 2323 times.
144461 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 144461 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144461 times.
288922 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 144299 times.
✓ Branch 1 taken 162 times.
144461 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 143664 times.
✓ Branch 1 taken 635 times.
144299 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 140745 times.
✓ Branch 1 taken 2919 times.
143664 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 140716 times.
✓ Branch 1 taken 29 times.
140745 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 138395 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
281182 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 138395 times.
✓ Branch 1 taken 2071 times.
140466 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 119190 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 119190 times.
✗ Branch 9 not taken.
238380 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 119190 {
344
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 x=X;
345
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 y=Y;
346
3/6
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
119190 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 119190 id=Id;
348 119190 clk=Clk;
349
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 floor_y=y;
350 119190 ceiling=false;
351 119190 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 119190 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119190 times.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
119190 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 119190 did_armos=true;
355 119190 script_spawned=false;
356
357 119190 d = guysbuf + (id & 0xFFF);
358 119190 hp = d->hp;
359 119190 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 119190 flags=d->flags;
364 119190 flags=d->flags;
365 119190 s_tile=d->s_tile; //secondary (additional) tile(s)
366 119190 type=d->type;
367 119190 dcset=d->cset;
368 119190 cs=dcset;
369
2/2
✓ Branch 0 taken 93046 times.
✓ Branch 1 taken 26144 times.
119190 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 119190 dp=d->dp;
371 119190 wdp=d->wdp;
372 119190 wpn=d->weapon;
373 119190 wpnsprite = d-> wpnsprite; //2.6 -Z
374 119190 rate=d->rate;
375 119190 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 dstep=d->step;
377 119190 homing=d->homing;
378 119190 dmisc1=d->attributes[0];
379 119190 dmisc2=d->attributes[1];
380 119190 dmisc3=d->attributes[2];
381 119190 dmisc4=d->attributes[3];
382 119190 dmisc5=d->attributes[4];
383 119190 dmisc6=d->attributes[5];
384 119190 dmisc7=d->attributes[6];
385 119190 dmisc8=d->attributes[7];
386 119190 dmisc9=d->attributes[8];
387 119190 dmisc10=d->attributes[9];
388 119190 dmisc11=d->attributes[10];
389 119190 dmisc12=d->attributes[11];
390 119190 dmisc13=d->attributes[12];
391 119190 dmisc14=d->attributes[13];
392 119190 dmisc15=d->attributes[14];
393 119190 dmisc16=d->attributes[15];
394 119190 dmisc17=d->attributes[16];
395 119190 dmisc18=d->attributes[17];
396 119190 dmisc19=d->attributes[18];
397 119190 dmisc20=d->attributes[19];
398 119190 dmisc21=d->attributes[20];
399 119190 dmisc22=d->attributes[21];
400 119190 dmisc23=d->attributes[22];
401 119190 dmisc24=d->attributes[23];
402 119190 dmisc25=d->attributes[24];
403 119190 dmisc26=d->attributes[25];
404 119190 dmisc27=d->attributes[26];
405 119190 dmisc28=d->attributes[27];
406 119190 dmisc29=d->attributes[28];
407 119190 dmisc30=d->attributes[29];
408 119190 dmisc31=d->attributes[30];
409 119190 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 8225 times.
✓ Branch 1 taken 110965 times.
119190 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110965 dmisc31 = dmisc32;
413 110965 dmisc32 = 0;
414 110965 }
415 119190 spr_shadow=d->spr_shadow;
416 119190 spr_death=d->spr_death;
417 119190 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4886790 times.
✓ Branch 1 taken 119190 times.
5005980 for(int32_t i=0; i<edefLAST255; i++)
420 4886790 defense[i]=d->defense[i];
421
422 119190 bgsfx=d->bgsfx;
423 119190 hitsfx=d->hitsfx;
424 119190 deadsfx=d->deadsfx;
425 119190 bosspal=d->bosspal;
426
427 119190 frozentile = d->frozentile;
428
429 119190 frozencset = d->frozencset;
430 119190 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1191900 times.
✓ Branch 1 taken 119190 times.
1311090 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 2026230 times.
✓ Branch 1 taken 119190 times.
2145420 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 119190 isCore = true; //t.b.a
436 119190 parentCore = 0; //t.b.a
437
438 119190 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3814080 times.
✓ Branch 1 taken 119190 times.
3933270 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3814080 times.
✓ Branch 1 taken 119190 times.
3933270 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 119190 script = d->script;
443
444
2/2
✓ Branch 0 taken 953520 times.
✓ Branch 1 taken 119190 times.
1072710 for ( int32_t q = 0; q < 8; q++ )
445 {
446 953520 initD[q] = d->initD[q];
447 953520 }
448
449 119190 stickclk = 0;
450 119190 submerged = false;
451 119190 didScriptThisFrame = false;
452 119190 activated_handle = std::nullopt;
453 119190 hitdir = -1;
454 119190 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8927 times.
✓ Branch 1 taken 110263 times.
119190 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8927 times.
✗ Branch 1 not taken.
8927 loadpalset(csBOSS,pSprite(bosspal));
462 8927 }
463
464
2/2
✓ Branch 0 taken 54277 times.
✓ Branch 1 taken 64913 times.
119190 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 54277 times.
✗ Branch 1 not taken.
54277 cont_sfx(bgsfx);
467 54277 }
468
469
2/2
✓ Branch 0 taken 93046 times.
✓ Branch 1 taken 26144 times.
119190 if(get_qr(qr_NEWENEMYTILES))
470 {
471 93046 o_tile=d->e_tile;
472 93046 frate = d->e_frate;
473 93046 }
474 else
475 {
476 26144 o_tile=d->tile;
477 26144 frate = d->frate;
478 }
479
480 119190 tile=0; //init to 0 here, but set it later.
481
482 119190 scripttile = -1;
483 119190 scriptflip = -1;
484 119190 do_animation = true;
485 119190 immortal = false;
486 119190 noSlide = false;
487 119190 deathexstate = -1;
488
489 119190 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5798 times.
✓ Branch 1 taken 113392 times.
✓ Branch 2 taken 5704 times.
✓ Branch 3 taken 94 times.
119190 if(o_tile==0 && type!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5704 times.
✗ Branch 1 not taken.
5704 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12948 times.
✓ Branch 5 taken 106242 times.
✓ Branch 6 taken 12948 times.
✗ Branch 7 not taken.
119190 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 106242 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106242 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 105543 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
106242 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 119190 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 119190 times.
✗ Branch 9 not taken.
119190 step = zslongToFix(dstep*100);
501
502
503 119190 item_set = d->item_set;
504 119190 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 93553 times.
✓ Branch 1 taken 25637 times.
119190 if(frate == 0)
507 25637 frate = 256;
508
509 119190 leader = itemguy = dying = scored = false;
510 119190 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 119151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
119190 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
5/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 119151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 16 times.
119190 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 119153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
119190 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 119153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
119190 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 119167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
119190 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
2/2
✓ Branch 0 taken 119162 times.
✓ Branch 1 taken 28 times.
119190 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
2/2
✓ Branch 0 taken 119162 times.
✓ Branch 1 taken 28 times.
119190 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119188 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
119190 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119188 times.
119190 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 2 }
530
531
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119188 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
119190 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 119190 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 118939 times.
✓ Branch 1 taken 251 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 118822 times.
✓ Branch 4 taken 368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 368 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 367 times.
119190 if((wpn==ewBomb || wpn==ewSBomb) && type!=eeOTHER && type!=eeFIRE && (type!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107998 times.
✓ Branch 5 taken 11192 times.
119190 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 119190 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✓ Branch 3 taken 101390 times.
119190 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✗ Branch 3 not taken.
17800 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✗ Branch 3 not taken.
17800 moveflags &= ~move_can_waterdrown;
548 17800 }
549
550 119190 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 119190 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 119190 times.
✗ Branch 1 not taken.
119190 weap_data = d->weap_data;
554 119190 }
555
556 118928 enemy::~enemy()
557 118928 {
558
1/2
✓ Branch 0 taken 118928 times.
✗ Branch 1 not taken.
118928 FFCore.destroySprite(this);
559
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 118914 times.
118928 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 Hero.setEaten(0);
562 14 hashero=false;
563 14 }
564 118928 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 396782 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 396782 int32_t yg = (special==spw_floater)?8:0;
574 396782 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
396782 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
396782 if(input_y == -1000)
579 input_y = dy;
580
581
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 396454 times.
793287 if(!(moveflags & move_ignore_screenedge)
582
5/6
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 396706 times.
✓ Branch 4 taken 335178 times.
✓ Branch 5 taken 61528 times.
396782 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
4/4
✓ Branch 0 taken 396556 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 396505 times.
✓ Branch 3 taken 51 times.
396706 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 328 return true;
585
586
6/6
✓ Branch 0 taken 278162 times.
✓ Branch 1 taken 118292 times.
✓ Branch 2 taken 207763 times.
✓ Branch 3 taken 70399 times.
✓ Branch 4 taken 1967 times.
✓ Branch 5 taken 205796 times.
396454 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276195 times.
276195 if(ispitfall(dx,dy))
589 return true;
590 276195 }
591
592 396454 bool flying = false;
593 396454 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396454 times.
396454 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 61519 times.
✓ Branch 1 taken 334935 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
396454 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61519 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61519 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
3/4
✓ Branch 0 taken 61519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57803 times.
✓ Branch 3 taken 3716 times.
61519 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 3716 return true;
614 57803 cansolid = true;
615 57803 flying = true;
616 }
617 57803 }
618
619 392738 dx = TRUNCATE_HALF_TILE(dx);
620 392738 dy = TRUNCATE_HALF_TILE(dy);
621
622
5/6
✓ Branch 0 taken 334935 times.
✓ Branch 1 taken 57803 times.
✓ Branch 2 taken 334935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 298582 times.
✓ Branch 5 taken 36353 times.
392738 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 356385 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 356385 times.
356385 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 356385 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 350399 times.
✓ Branch 1 taken 5986 times.
356385 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
356385 if (!s1 || !s1->valid) s1 = s0;
634
3/4
✓ Branch 0 taken 350399 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 350399 times.
✗ Branch 3 not taken.
356385 if (!s2 || !s2->valid) s2 = s0;
635
636 356385 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
356385 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 356385 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 356385 times.
356385 newcombo c2 = combobuf[ci2];
641
642 356385 int32_t b=1;
643
2/2
✓ Branch 0 taken 170119 times.
✓ Branch 1 taken 186266 times.
356385 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 167084 times.
✓ Branch 1 taken 189301 times.
356385 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45689 times.
✓ Branch 3 taken 310696 times.
✓ Branch 4 taken 45689 times.
✗ Branch 5 not taken.
356385 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool pit = ispitfall(dx,dy);
654
655
6/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 236798 times.
✓ Branch 3 taken 119587 times.
✓ Branch 4 taken 236798 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82587 times.
✓ Branch 7 taken 154211 times.
356385 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
6/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241968 times.
✓ Branch 3 taken 114417 times.
✓ Branch 4 taken 241968 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 70399 times.
✓ Branch 7 taken 171569 times.
356385 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 57803 times.
✓ Branch 1 taken 298582 times.
356385 if(!cansolid)
662 {
663 298582 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
298582 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 298582 else cwalkflag |= c1.walk & 0xF;
678 298582 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (s2)
680 {
681
2/2
✓ Branch 0 taken 1261 times.
✓ Branch 1 taken 297321 times.
298582 if (c2.type == cBRIDGE)
682 {
683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1261 times.
1261 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 1261 int efflag = (c2.walk & 0xF0)>>4;
686 1261 int newsolid = (c2.walk & 0xF);
687 1261 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 1261 }
689 else cwalkflag &= c2.walk;
690 1261 }
691 297321 else cwalkflag |= c2.walk & 0xF;
692 298582 }
693
2/2
✓ Branch 0 taken 50862 times.
✓ Branch 1 taken 247720 times.
298582 if(cwalkflag & b)
694 50862 return true;
695 247720 }
696
3/6
✓ Branch 0 taken 305523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 305523 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 305523 times.
305523 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 22544 times.
✓ Branch 1 taken 282979 times.
✓ Branch 2 taken 22544 times.
✗ Branch 3 not taken.
305523 else if(wtr && !canwtr)
705 return true;
706
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 305400 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
305523 else if(pit && !canpit)
707 return true;
708
709 305523 return false;
710 396782 }
711
712 181035 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 93117 times.
✓ Branch 1 taken 87918 times.
✓ Branch 2 taken 93117 times.
✗ Branch 3 not taken.
181035 if(!(dx || dy)) return true;
715 181035 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 181035 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
4/4
✓ Branch 0 taken 178930 times.
✓ Branch 1 taken 2105 times.
✓ Branch 2 taken 131817 times.
✓ Branch 3 taken 47113 times.
181035 if(!ign_sv && dy < 0) //check gravity
718 {
719
3/4
✓ Branch 0 taken 40102 times.
✓ Branch 1 taken 7011 times.
✓ Branch 2 taken 40102 times.
✗ Branch 3 not taken.
47113 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 47113 }
722
723
2/4
✓ Branch 0 taken 181035 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181035 times.
181035 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 87918 times.
✓ Branch 1 taken 93117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87918 times.
181035 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 41442 times.
✓ Branch 1 taken 46476 times.
87918 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 41442 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41442 times.
41442 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 41442 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 80133 times.
✓ Branch 1 taken 23099 times.
103232 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
2/2
✓ Branch 0 taken 61790 times.
✓ Branch 1 taken 18343 times.
80133 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 18343 return false;
735 61790 }
736
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 22475 times.
23099 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 624 return false;
738
4/4
✓ Branch 0 taken 18723 times.
✓ Branch 1 taken 3752 times.
✓ Branch 2 taken 18722 times.
✓ Branch 3 taken 1 times.
22475 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 1 return false;
740 22474 }
741 else
742 {
743 46476 int mx = (rx+dx).getCeil();
744 46476 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 79733 times.
✓ Branch 1 taken 23855 times.
103588 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 57112 times.
✓ Branch 1 taken 22621 times.
79733 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 22621 return false;
749 57112 }
750
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 23646 times.
23855 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 209 return false;
752
3/4
✓ Branch 0 taken 20207 times.
✓ Branch 1 taken 3439 times.
✓ Branch 2 taken 20207 times.
✗ Branch 3 not taken.
23646 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 46120 }
756
2/4
✓ Branch 0 taken 93117 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93117 times.
93117 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 44733 times.
93117 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 special = (special==spw_clipbottomright)?spw_none:special;
761 48384 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 76133 times.
✓ Branch 1 taken 23042 times.
99175 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 50791 times.
✓ Branch 1 taken 25342 times.
76133 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 25342 return false;
766 50791 }
767
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 22759 times.
23042 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 283 return false;
769
3/4
✓ Branch 0 taken 19000 times.
✓ Branch 1 taken 3759 times.
✓ Branch 2 taken 19000 times.
✗ Branch 3 not taken.
22759 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 22759 }
772 else
773 {
774 44733 int my = (ry+dy).getCeil();
775 44733 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 69864 times.
✓ Branch 1 taken 20923 times.
90787 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
2/2
✓ Branch 0 taken 46054 times.
✓ Branch 1 taken 23810 times.
69864 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 23810 return false;
780 46054 }
781
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 20896 times.
20923 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 27 return false;
783
3/4
✓ Branch 0 taken 17493 times.
✓ Branch 1 taken 3403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17493 times.
20896 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 43655 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 89775 return true;
792 181035 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 113155 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 113155 bool ret = true;
836
7/8
✓ Branch 0 taken 112634 times.
✓ Branch 1 taken 521 times.
✓ Branch 2 taken 32008 times.
✓ Branch 3 taken 80626 times.
✓ Branch 4 taken 28103 times.
✓ Branch 5 taken 3905 times.
✓ Branch 6 taken 28103 times.
✗ Branch 7 not taken.
113155 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 113155 const int scl = 2;
839
4/4
✓ Branch 0 taken 15916 times.
✓ Branch 1 taken 125286 times.
✓ Branch 2 taken 28765 times.
✓ Branch 3 taken 112437 times.
141202 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 14871 times.
✓ Branch 1 taken 13894 times.
28765 if(abs(dx) > abs(dy))
842 {
843 14871 int32_t tdx = dx.sign() * scl;
844
2/2
✓ Branch 0 taken 14099 times.
✓ Branch 1 taken 772 times.
14871 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 14099 dx -= tdx;
846 else
847 {
848
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 387 times.
772 if(earlyret) return false;
849 385 dx = tdx;
850 385 ret = false;
851 }
852 14484 }
853 else
854 {
855 13894 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 13168 times.
✓ Branch 1 taken 726 times.
13894 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 13168 dy -= tdy;
858 else
859 {
860
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 331 times.
726 if(earlyret) return false;
861 395 dy = tdy;
862 395 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 48813 times.
✓ Branch 1 taken 63624 times.
112437 if(dx)
868 {
869
2/2
✓ Branch 0 taken 45302 times.
✓ Branch 1 taken 18322 times.
63624 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 45302 x += dx;
871 else
872 {
873
2/2
✓ Branch 0 taken 16759 times.
✓ Branch 1 taken 1563 times.
18322 if(earlyret) return false;
874 1563 ret = false;
875 1563 int xsign = dx.sign();
876
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1563 times.
1587 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 24 x += xsign;
879 24 dx -= xsign;
880 }
881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1563 times.
1563 if(dx)
882 {
883 1563 dx.doDecBound(0,-9999, 0,9999);
884
3/6
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1563 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1563 times.
✗ Branch 5 not taken.
24270 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885
2/2
✓ Branch 0 taken 794 times.
✓ Branch 1 taken 21913 times.
22707 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 794 retval = val;
888 794 return BSEARCH_CONTINUE_AWAY0;
889 }
890 21913 else return BSEARCH_CONTINUE_TOWARD0;
891 22707 });
892 1563 x += dx;
893 1563 }
894 }
895 46865 }
896
2/2
✓ Branch 0 taken 33883 times.
✓ Branch 1 taken 61795 times.
95678 if(dy)
897 {
898
2/2
✓ Branch 0 taken 42811 times.
✓ Branch 1 taken 18984 times.
61795 if(scr_canmove(0, dy, special, kb, ign_sv))
899 42811 y += dy;
900 else
901 {
902
2/2
✓ Branch 0 taken 16954 times.
✓ Branch 1 taken 2030 times.
18984 if(earlyret) return false;
903 2030 ret = false;
904 2030 int ysign = dy.sign();
905
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 2030 times.
2058 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 28 y += ysign;
908 28 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(dy)
911 {
912 2030 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 2030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2030 times.
✗ Branch 5 not taken.
31294 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 28448 times.
29264 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 816 retval = val;
917 816 return BSEARCH_CONTINUE_AWAY0;
918 }
919 28448 else return BSEARCH_CONTINUE_TOWARD0;
920 29264 });
921 2030 y += dy;
922 2030 }
923 }
924 44841 }
925 78724 return ret;
926 113155 }
927
928 51123 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 51115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
51123 static const zfix diagrate = zslongToFix(7071);
931
7/13
✓ Branch 0 taken 51123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51123 times.
✓ Branch 4 taken 13029 times.
✓ Branch 5 taken 11932 times.
✓ Branch 6 taken 13226 times.
✓ Branch 7 taken 12792 times.
✓ Branch 8 taken 144 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
51123 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 13029 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 11932 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 13226 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 12792 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 144 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 51123 }
952
953 9517 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 9517 double v = degrees.getFloat() * PI / 180.0;
956 9517 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 9517 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 39290 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 39290 zfix tx = x, ty = y;
971 39290 bool ret = moveDir(dir, px, special, kb, true);
972 39290 x = tx;
973 39290 y = ty;
974 39290 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 39027235 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 39024016 times.
✓ Branch 1 taken 3219 times.
39027235 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 3173 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 32 times.
3219 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
991
2/2
✓ Branch 0 taken 3173 times.
✓ Branch 1 taken 46 times.
3219 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 23 times.
46 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 23 stop_bgsfx(index);
1005 23 return true;
1006 }
1007 else
1008 {
1009 23 try_death(true); //Force death
1010 23 ++fallclk; //force another frame of falling
1011 }
1012 23 }
1013
1014 3196 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 3196 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 int32_t spd = spr.speed ? spr.speed : 1;
1018 3196 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 1700 times.
3196 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 3196 }
1021 39027212 return false;
1022 39027235 }
1023
1024 // Handle drowning in water
1025 39024016 bool enemy::do_drowning(int32_t index)
1026 {
1027
2/2
✓ Branch 0 taken 39022607 times.
✓ Branch 1 taken 1409 times.
39024016 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x));
1030 //!TODO: Drown SFX
1031
2/2
✓ Branch 0 taken 1367 times.
✓ Branch 1 taken 42 times.
1409 if(!--drownclk)
1032 {
1033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
42 else if(dying) //Give 1 frame for script revival
1036 {
1037
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 21 stop_bgsfx(index);
1045 21 return true;
1046 }
1047 else
1048 {
1049 21 try_death(true); //Force death
1050 21 ++drownclk; //force another frame of falling
1051 }
1052 21 }
1053
1054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1388 times.
1388 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 1388 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 1388 cs = spr.csets & 0xF;
1057
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 int32_t fr = spr.frames ? spr.frames : 1;
1058
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 int32_t spd = spr.speed ? spr.speed : 1;
1059 1388 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060
2/2
✓ Branch 0 taken 1177 times.
✓ Branch 1 taken 211 times.
1388 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 1388 }
1062 39023995 return false;
1063 39024016 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 39714025 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 29981 times.
✓ Branch 1 taken 39684044 times.
39714025 if(immortal)
1071 {
1072 29981 dying = false;
1073 29981 return false;
1074 }
1075
2/2
✓ Branch 0 taken 794520 times.
✓ Branch 1 taken 38889524 times.
39684044 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 794519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
794520 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 794520 --clk2;
1083
1084
4/4
✓ Branch 0 taken 725657 times.
✓ Branch 1 taken 68863 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3242 times.
794520 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41978 times.
✓ Branch 1 taken 683679 times.
725657 && hp>-1000) // not killed by ringleader
1086 38736 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 749620 times.
✓ Branch 1 taken 44900 times.
794520 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 44196 times.
✓ Branch 1 taken 704 times.
44900 if(flags&guy_never_return)
1091 704 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 44822 times.
✓ Branch 1 taken 78 times.
44900 if(leader)
1094 78 kill_em_all();
1095
1096 44900 leave_item();
1097 44900 }
1098
1099 794520 stop_bgsfx(index);
1100 794520 return (clk2==0);
1101 }
1102
1103 38889524 return false;
1104 39714025 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 39027491 bool enemy::animate(int32_t index)
1110 {
1111 39027491 update_current_screen();
1112
2/2
✓ Branch 0 taken 1785810 times.
✓ Branch 1 taken 37241681 times.
39027491 if(sclk <= 0) hitdir = -1;
1113
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 39027235 times.
39027491 if(switch_hooked)
1114 {
1115
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1116 {
1117 //Run its script
1118 if (!didScriptThisFrame)
1119 {
1120 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1121 {
1122 return 0; //Avoid NULLPO if this object deleted itself
1123 }
1124 }
1125 }
1126 256 return false;
1127 }
1128
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39027212 times.
39027235 if(do_falling(index)) return true;
1129
2/2
✓ Branch 0 taken 3196 times.
✓ Branch 1 taken 39024016 times.
39027212 else if(fallclk)
1130 {
1131 //clks
1132
2/2
✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 921 times.
3196 if(hclk>0)
1133 921 --hclk;
1134
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if(stunclk>0)
1135 --stunclk;
1136
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if ( frozenclock > 0 )
1137 --frozenclock;
1138
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if(hashero)
1139 {
1140 Hero.setX(x);
1141 Hero.setY(y);
1142 Hero.fallCombo = fallCombo;
1143 Hero.fallclk = fallclk;
1144
1145 if(hashero)
1146 {
1147 hashero = false; //Let Hero go if falling
1148 Hero.setEaten(0);
1149 }
1150 }
1151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3196 times.
3196 if (!didScriptThisFrame)
1152 {
1153 3196 run_script(MODE_NORMAL);
1154 3196 }
1155 3196 return false;
1156 }
1157
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 39023995 times.
39024016 if(do_drowning(index)) return true;
1158
2/2
✓ Branch 0 taken 1388 times.
✓ Branch 1 taken 39022607 times.
39023995 else if(drownclk)
1159 {
1160 //clks
1161
2/2
✓ Branch 0 taken 853 times.
✓ Branch 1 taken 535 times.
1388 if(hclk>0)
1162 535 --hclk;
1163
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if(stunclk>0)
1164 --stunclk;
1165
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if ( frozenclock > 0 )
1166 --frozenclock;
1167
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if(hashero)
1168 {
1169 Hero.setX(x);
1170 Hero.setY(y);
1171 Hero.drownclk = drownclk;
1172
1173 if(hashero)
1174 {
1175 hashero = false; //Let Hero go if falling
1176 Hero.setEaten(0);
1177 }
1178 }
1179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1388 times.
1388 if (!didScriptThisFrame)
1180 {
1181 1388 run_script(MODE_NORMAL);
1182 1388 }
1183 1388 return false;
1184 }
1185 39022607 int32_t nx = real_x(x);
1186 39022607 int32_t ny = real_y(y);
1187
1188
4/4
✓ Branch 0 taken 28201979 times.
✓ Branch 1 taken 10820628 times.
✓ Branch 2 taken 5865377 times.
✓ Branch 3 taken 22336602 times.
39022607 if(ox!=nx || oy!=ny)
1189 {
1190 16686005 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1191 16686005 }
1192
1193 39022607 ox = nx;
1194 39022607 oy = ny;
1195
1196 // Maybe they fell off the bottom in sideview, or were moved by a script.
1197
1198 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1199
2/2
✓ Branch 0 taken 29986 times.
✓ Branch 1 taken 38992621 times.
39022607 if ( immortal )
1200 {
1201 //skip, as it can go out of bounds, from immortality
1202 29986 }
1203
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38992621 times.
✓ Branch 2 taken 38992621 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38992621 times.
38992621 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1204 {
1205 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1206 }
1207
2/2
✓ Branch 0 taken 38961005 times.
✓ Branch 1 taken 31616 times.
38992621 else if (OUTOFBOUNDS(id, x, y))
1208 {
1209 31616 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1210 31616 }
1211 //fall down
1212 39022607 handle_termv();
1213
6/6
✓ Branch 0 taken 27570660 times.
✓ Branch 1 taken 11451947 times.
✓ Branch 2 taken 11181564 times.
✓ Branch 3 taken 27841043 times.
✓ Branch 4 taken 518775 times.
✓ Branch 5 taken 10662789 times.
39022607 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 10275091 times.
10662789 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1220 {
1221 157378 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 157378 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 157378 y+=fall/100;
1242
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= get_terminalv_fall())
1243 139566 fall += get_grav_fall();
1244 }
1245 157378 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 277 do_fix(y, 8); //Fix position
1252 277 }
1253
1254 230320 fall = 0;
1255 }
1256 387698 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= get_terminalv_fall())
1287 fall += get_grav_fall();
1288 }
1289 }
1290 387698 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10275091 times.
10275091 if (!(moveflags & move_no_fake_z))
1294 {
1295
2/2
✓ Branch 0 taken 5707028 times.
✓ Branch 1 taken 4568063 times.
10275091 if(fakefall!=0)
1296 4568063 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5707028 times.
10275091 if(fakez<0)
1299 4568063 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5707028 times.
5707028 else if(fakefall <= get_terminalv_fall())
1301 5707028 fakefall += get_grav_fall();
1302
1303
5/6
✓ Branch 0 taken 10275091 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5707028 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 1124718 times.
10275091 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 10275091 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10275091 times.
10275091 if (!(moveflags & move_no_real_z))
1306 {
1307
2/2
✓ Branch 0 taken 6129417 times.
✓ Branch 1 taken 4145674 times.
10275091 if(fall!=0)
1308 4145674 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 4120761 times.
✓ Branch 1 taken 6154330 times.
10275091 if(z<0)
1311 4120761 z = fall = 0;
1312
2/2
✓ Branch 0 taken 16075 times.
✓ Branch 1 taken 6138255 times.
6154330 else if(fall <= get_terminalv_fall())
1313 6138255 fall += get_grav_fall();
1314
1315
6/6
✓ Branch 0 taken 10222435 times.
✓ Branch 1 taken 52656 times.
✓ Branch 2 taken 6101674 times.
✓ Branch 3 taken 4120761 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 1110985 times.
10275091 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 10275091 }
1317
1318 }
1319 10662789 }
1320 39022607 handle_termv();
1321
10/10
✓ Branch 0 taken 30760564 times.
✓ Branch 1 taken 8262043 times.
✓ Branch 2 taken 29433125 times.
✓ Branch 3 taken 1327439 times.
✓ Branch 4 taken 29294316 times.
✓ Branch 5 taken 138809 times.
✓ Branch 6 taken 4329044 times.
✓ Branch 7 taken 26431520 times.
✓ Branch 8 taken 19103256 times.
✓ Branch 9 taken 23432300 times.
39022607 if (can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1322 {
1323
4/4
✓ Branch 0 taken 23016776 times.
✓ Branch 1 taken 415524 times.
✓ Branch 2 taken 13153465 times.
✓ Branch 3 taken 9863311 times.
23432300 if (!isSideViewGravity() && (moveflags & move_can_pitfall))
1324 9863311 fallCombo = check_pits();
1325
4/4
✓ Branch 0 taken 415524 times.
✓ Branch 1 taken 23016776 times.
✓ Branch 2 taken 659954 times.
✓ Branch 3 taken 22356822 times.
23432300 if (!(isSideViewGravity() && get_qr(qr_OLD_SPRITE_FALL_DROWN)) && (moveflags & move_can_waterdrown))
1326 659954 drownCombo = check_water();
1327 23432300 }
1328
1329 77229119 runKnockback(); //scripted knockback handling
1330
1331 // clk is incremented here
1332
2/2
✓ Branch 0 taken 74869461 times.
✓ Branch 1 taken 2359658 times.
77229119 if(++clk >= frate)
1333 2359658 clk=0;
1334
1335 // hit and death handling
1336
2/2
✓ Branch 0 taken 1324357 times.
✓ Branch 1 taken 75904762 times.
77229119 if(hclk>0)
1337 1324357 --hclk;
1338
1339
2/2
✓ Branch 0 taken 684748 times.
✓ Branch 1 taken 76544371 times.
77229119 if(stunclk>0)
1340 684748 --stunclk;
1341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77229119 times.
77229119 if ( frozenclock > 0 )
1342 --frozenclock;
1343
1344
5/6
✓ Branch 0 taken 22710 times.
✓ Branch 1 taken 77206409 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 22521 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 189 times.
77229119 if(ceiling && z <= 0 && fakez <= 0)
1345 189 ceiling = false;
1346
1347 77229119 try_death();
1348
1349 77229119 scored=false;
1350
1351 77229119 ++c_clk;
1352
1353 //Run its script
1354
2/2
✓ Branch 0 taken 38252937 times.
✓ Branch 1 taken 38976182 times.
77229119 if (!didScriptThisFrame)
1355 {
1356
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 38976176 times.
38976182 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1357 {
1358 6 return 0; //Avoid NULLPO if this object deleted itself
1359 }
1360 38976176 }
1361
1362 // returns true when enemy is defeated
1363 77229113 return Dead(index);
1364 77234003 }
1365
1366 39799703 bool enemy::setSolid(bool set)
1367 {
1368
1/2
✓ Branch 0 taken 39799703 times.
✗ Branch 1 not taken.
39799703 bool actual = set && !isSubmerged();
1369 39799703 bool ret = solid_object::setSolid(actual);
1370 39799703 solid = set;
1371 39799703 return ret;
1372 }
1373 void enemy::doContactDamage(int32_t hdir)
1374 {
1375 Hero.hithero(guys.find(this), hdir);
1376 }
1377
1378 29704 void enemy::solid_push(solid_object *obj)
1379 {
1380
1/2
✓ Branch 0 taken 29704 times.
✗ Branch 1 not taken.
29704 if(obj == this) return; //can't push self
1381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29704 times.
29704 if(moveflags&move_not_pushable) return; //not pushable
1382 29704 zfix dx, dy;
1383 29704 int32_t hdir = -1;
1384 29704 solid_push_int(obj,dx,dy,hdir,true);
1385
1386
4/4
✓ Branch 0 taken 29591 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 336 times.
✓ Branch 3 taken 29255 times.
29704 if(!dx && !dy) return;
1387
1388 449 bool t = obj->getTempNonsolid();
1389 449 obj->setTempNonsolid(true);
1390
1391 449 int32_t ydir = dy > 0 ? down : up;
1392 449 int32_t xdir = dx > 0 ? right : left;
1393
1394 449 auto special = isflier(id) ? spw_floater : spw_none;
1395
2/2
✓ Branch 0 taken 397 times.
✓ Branch 1 taken 52 times.
449 if(!movexy(dx,dy,special,true,true))
1396 {
1397 //Crushed?
1398 52 }
1399
1400 449 obj->setTempNonsolid(t);
1401 29704 }
1402 29704 bool enemy::is_unpushable() const
1403 {
1404 29704 return isSubmerged();
1405 }
1406 29163 bool enemy::sideview_mode() const
1407 {
1408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29163 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1409 }
1410
1411 3236 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1412 {
1413 3236 int32_t yg = (special==spw_floater)?8:0;
1414 3236 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1415
1416
8/10
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2370 times.
✓ Branch 9 taken 3240 times.
3236 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1417 4736 return true;
1418
1419 3240 bool isInDungeon = isdungeon(screen_spawned);
1420
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3240 if(isInDungeon || special==spw_wizzrobe)
1421 {
1422
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2377 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2978 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1423 1199 return true;
1424
1425
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1426
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1427 return true;
1428 595 }
1429
1430
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1431 {
1432
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1433
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1434 return true;
1435 62 }
1436
1437
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1438 {
1439 case spw_clipbottomright:
1440 if(dy>=128 || dx>=208) return true;
1441 break;
1442 case spw_clipright:
1443 break; //if(x>=208) return true; break;
1444
1445 case spw_wizzrobe: // fall through
1446 case spw_floater: // Special case for fliers and wizzrobes - hack!
1447 {
1448
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1449 {
1450
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1451
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1452 595 }
1453 857 return false;
1454 }
1455 }
1456
1457 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1458 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1459
1460 if(special==spw_water)
1461 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1462
1463 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1464 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1465 870 }
1466
1467 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1468 {
1469 6575 bool kb = false;
1470 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1471
1472
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1473 return true;
1474
1475
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1476 {
1477
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1478 return true;
1479
1480
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1481 return true;
1482 1513 }
1483
1484
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1485 {
1486
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1487
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1488 return true;
1489 6575 }
1490
1491
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1492 {
1493
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1495 }
1496 else
1497 {
1498
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1499
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1502 }
1503 6575 }
1504
1505 // returns true if cannot walk
1506 32942792 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1507 {
1508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32942792 times.
32942792 if(moveflags & move_new_movement)
1509 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1510 32942792 int32_t yg = (special==spw_floater)?8:0;
1511 32942792 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1512
2/2
✓ Branch 0 taken 3888710 times.
✓ Branch 1 taken 29054082 times.
32942792 switch(dir)
1513 {
1514 case l_down:
1515 case r_down:
1516 case down:
1517 case 11: //r_down
1518 case 12: //down
1519 case 13: //l_down
1520 {
1521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3888710 times.
3888710 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1522 {
1523
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3888702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3888710 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1524 {
1525 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1526
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1527 8 }
1528 3888710 }
1529 3888710 break;
1530 }
1531 }
1532
2/2
✓ Branch 0 taken 3876995 times.
✓ Branch 1 taken 29065797 times.
32942792 switch(dir)
1533 {
1534 case r_up:
1535 case r_down:
1536 case right:
1537 case 9: //r_up
1538 case 10: //right
1539 case 11: //r_down
1540 {
1541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3876995 times.
3876995 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1542 {
1543
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 3876950 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
3876995 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1544 {
1545 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1546
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 dx += zc_max(hit_width-16,0);
1547 45 }
1548 3876995 }
1549 3876995 break;
1550 }
1551 }
1552
1553
10/10
✓ Branch 0 taken 22398333 times.
✓ Branch 1 taken 10544459 times.
✓ Branch 2 taken 8940039 times.
✓ Branch 3 taken 1604420 times.
✓ Branch 4 taken 10505543 times.
✓ Branch 5 taken 38916 times.
✓ Branch 6 taken 10481553 times.
✓ Branch 7 taken 23990 times.
✓ Branch 8 taken 22453602 times.
✓ Branch 9 taken 32935155 times.
32942792 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1554 44914841 return true;
1555
1556 32935155 bool isInDungeon = isdungeon(screen_spawned);
1557
4/4
✓ Branch 0 taken 4413396 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 4401640 times.
32935155 if(isInDungeon || special==spw_wizzrobe)
1558 {
1559
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1560 11487907 return true;
1561
1562
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1563
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1564 113905 return true;
1565 5785039 }
1566
1567
6/6
✓ Branch 0 taken 3260136 times.
✓ Branch 1 taken 6926543 times.
✓ Branch 2 taken 907960 times.
✓ Branch 3 taken 2352176 times.
✓ Branch 4 taken 61002 times.
✓ Branch 5 taken 846958 times.
10186679 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1568 {
1569
4/4
✓ Branch 0 taken 3191204 times.
✓ Branch 1 taken 7930 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 3190205 times.
6389416 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1570
4/4
✓ Branch 0 taken 3191005 times.
✓ Branch 1 taken 199 times.
✓ Branch 2 taken 3190282 times.
✓ Branch 3 taken 723 times.
3191204 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1571 8929 return true;
1572 3190205 }
1573
1574
4/4
✓ Branch 0 taken 7810305 times.
✓ Branch 1 taken 2360740 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5732 times.
10177750 switch(special)
1575 {
1576 case spw_clipbottomright:
1577
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1578 707 break;
1579 case spw_clipright:
1580 5732 break; //if(input_x>=208) return true; break;
1581
1582 case spw_wizzrobe: // fall through
1583 case spw_floater: // Special case for fliers and wizzrobes - hack!
1584 {
1585
2/2
✓ Branch 0 taken 3168626 times.
✓ Branch 1 taken 4641679 times.
7810305 if(isInDungeon)
1586 {
1587
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1588
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1589 4639539 }
1590 7808165 return false;
1591 }
1592 }
1593
1594 2367179 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1595
2/2
✓ Branch 0 taken 564791 times.
✓ Branch 1 taken 1802388 times.
2367179 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1596
1597
2/2
✓ Branch 0 taken 439102 times.
✓ Branch 1 taken 1928077 times.
2367179 if(special==spw_water)
1598
2/2
✓ Branch 0 taken 17784 times.
✓ Branch 1 taken 421318 times.
439102 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1599
1600
2/2
✓ Branch 0 taken 1711908 times.
✓ Branch 1 taken 216169 times.
1928077 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1601 {
1602
4/4
✓ Branch 0 taken 1228217 times.
✓ Branch 1 taken 483691 times.
✓ Branch 2 taken 1218180 times.
✓ Branch 3 taken 10037 times.
2930088 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1603
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203600 times.
1218180 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1604 }
1605 else
1606 {
1607
4/4
✓ Branch 0 taken 164129 times.
✓ Branch 1 taken 52040 times.
✓ Branch 2 taken 163777 times.
✓ Branch 3 taken 352 times.
379946 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1608
4/4
✓ Branch 0 taken 162854 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 162838 times.
✓ Branch 3 taken 16 times.
163777 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
4/4
✓ Branch 0 taken 152476 times.
✓ Branch 1 taken 10362 times.
✓ Branch 2 taken 152461 times.
✓ Branch 3 taken 15 times.
162838 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1610
2/2
✓ Branch 0 taken 152158 times.
✓ Branch 1 taken 303 times.
152461 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1611 }
1612 10571176 }
1613
1614 496901 bool enemy::isOnSideviewPlatform()
1615 {
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1619 return false;
1620
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1622
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1623 {
1624
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1625
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1627 64328 }
1628 215641 return false;
1629 496901 }
1630
1631 // Stops playing the given sound only if there are no enemies left to play it
1632 797513 void enemy::stop_bgsfx(int32_t index)
1633 {
1634
2/2
✓ Branch 0 taken 781310 times.
✓ Branch 1 taken 16203 times.
797513 if(bgsfx<=0)
1635 781310 return;
1636
1637 // Look for other enemies with the same bgsfx
1638
2/2
✓ Branch 0 taken 55203 times.
✓ Branch 1 taken 9313 times.
64516 for(int32_t i=0; i<guys.Count(); i++)
1639 {
1640
4/4
✓ Branch 0 taken 43166 times.
✓ Branch 1 taken 12037 times.
✓ Branch 2 taken 6890 times.
✓ Branch 3 taken 36276 times.
55203 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1641 6890 return;
1642 48313 }
1643
1644 9313 stop_sfx(bgsfx);
1645 797513 }
1646
1647
1648 // to allow for different sfx on defeating enemy
1649 41726 void enemy::death_sfx()
1650 {
1651
2/2
✓ Branch 0 taken 41441 times.
✓ Branch 1 taken 285 times.
41726 if(deadsfx > 0) sfx(deadsfx,pan(x));
1652 41726 }
1653
1654 void enemy::move(zfix dx,zfix dy)
1655 {
1656 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1657 {
1658 x+=dx;
1659 y+=dy;
1660 }
1661 }
1662
1663 19033497 void enemy::move(zfix s)
1664 {
1665
9/10
✓ Branch 0 taken 19033458 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18924349 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
19033497 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1666 {
1667 19032453 sprite::move(s);
1668 19032453 }
1669 19033497 }
1670
1671 45202 void enemy::leave_item()
1672 {
1673 45202 int32_t drop_item = select_dropitem(item_set, x, y);
1674 45202 int32_t thedropset = item_set;
1675
1676 45202 std::vector<int32_t> &ev = FFCore.eventData;
1677 45202 ev.clear();
1678 45202 ev.push_back(getUID());
1679 45202 ev.push_back(drop_item*10000);
1680 45202 ev.push_back(thedropset*10000);
1681
1682 45202 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1683 45202 drop_item = vbound(ev[1] / 10000,-2,255);
1684 45202 thedropset = ev[2] / 10000;
1685 45202 ev.clear();
1686
1/2
✓ Branch 0 taken 45202 times.
✗ Branch 1 not taken.
45202 if(drop_item == -2)
1687 {
1688 drop_item = select_dropitem(thedropset,x,y);
1689 }
1690
1691
6/6
✓ Branch 0 taken 17094 times.
✓ Branch 1 taken 28108 times.
✓ Branch 2 taken 921 times.
✓ Branch 3 taken 16173 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 752 times.
45202 if(drop_item>=0&&((itemsbuf[drop_item].type!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1692 {
1693 item* itm;
1694
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 16376 times.
16925 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1695 {
1696
10/20
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 549 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 549 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 549 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 549 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 549 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 549 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 549 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 549 times.
✗ Branch 19 not taken.
549 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1697 549 }
1698 else
1699 {
1700
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14656 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16376 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1701
4/8
✓ Branch 0 taken 14656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14656 times.
✗ Branch 7 not taken.
14656 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1702 }
1703 16925 itm->from_dropset = thedropset;
1704 16925 add_item_for_screen(screen_spawned, itm);
1705
1706 16925 ev.push_back(getUID());
1707 16925 ev.push_back(itm->getUID());
1708
1709 16925 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1710 16925 ev.clear();
1711 16925 }
1712 45202 }
1713
1714 // auomatically kill off enemy (for rooms with ringleaders)
1715 419 void enemy::kickbucket()
1716 {
1717
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 387 times.
✗ Branch 3 not taken.
419 if(!superman && !(flags&guy_ignore_kill_all))
1718 387 hp=-1000; // don't call death_sfx()
1719 419 }
1720
1721 27212 bool enemy::isSubmerged() const
1722 {
1723 27212 return submerged;
1724 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1725 }
1726
1727 20952 void enemy::FireBreath(bool seekhero)
1728 {
1729
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1730 return;
1731
1732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1733 {
1734 dmisc1 = e1tEACHTILE;
1735 FireWeapon();
1736 return;
1737 }
1738
1739 20952 float fire_angle=0.0;
1740 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1741
1742
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1743 {
1744 xoff += hxofs;
1745 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1746 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1747 else
1748 xoff += (hit_width / 2) - 8;
1749 }
1750
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1751 {
1752 yoff += hyofs;
1753 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1754 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1755 else
1756 yoff += (hit_height / 2) - 8;
1757 }
1758
1759
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1760 {
1761
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1762 {
1763 case down:
1764 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1765 3079 wx=x;
1766 3079 wy=y+8;
1767 3079 break;
1768
1769 case -1:
1770 case up:
1771 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1772 3297 wx=x;
1773 3297 wy=y-8;
1774 3297 break;
1775
1776 case left:
1777 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1778 5287 wx=x-8;
1779 5287 wy=y;
1780 5287 break;
1781
1782 case right:
1783 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1784 4208 wx=x+8;
1785 4208 wy=y;
1786 4208 break;
1787 }
1788
1789
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1790 {
1791
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1797
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1798
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1799 15735 }
1800 15871 }
1801 else
1802 {
1803 5081 wx = x;
1804 5081 wy = y;
1805 }
1806
1807
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1808 20952 sfx(wpnsfx(wpn),pan(x));
1809
1810 20952 int32_t i=Ewpns.Count()-1;
1811 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1812 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1813
1814
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1815 {
1816 7957 ew->angular=true;
1817 7957 ew->angle=fire_angle;
1818 7957 }
1819
1820
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1821 {
1822 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1824 20359 }
1825
1826
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1827 {
1828 766199 Ewpns.swap(j,j-1);
1829 766199 }
1830 20952 }
1831
1832 45994 void enemy::FireWeapon()
1833 {
1834 /*
1835 * Type:
1836 * 0x01: Boss fireball
1837 * 0x02: Seeks Hero
1838 * 0x04: Fast projectile
1839 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1840 */
1841
1842
2/2
✓ Branch 0 taken 45863 times.
✓ Branch 1 taken 131 times.
45994 if (wpn < 1) return;
1843
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 45863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
45863 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1844 return;
1845
1846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45863 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1847 dmisc1 = e1tEACHTILE;
1848
1849 45863 int32_t xoff = 0;
1850 45863 int32_t yoff = 0;
1851
1/2
✓ Branch 0 taken 45863 times.
✗ Branch 1 not taken.
45863 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1852 {
1853 xoff += hxofs;
1854 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1855 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1856 else
1857 xoff += (hit_width / 2) - 8;
1858 }
1859
1/2
✓ Branch 0 taken 45863 times.
✗ Branch 1 not taken.
45863 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1860 {
1861 yoff += hyofs;
1862 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1863 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1864 else
1865 yoff += (hit_height / 2) - 8;
1866 }
1867
1868 // TODO(crash): check that .add succeeds.
1869
1870
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 42856 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 424 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
45863 switch(dmisc1)
1871 {
1872 case e1t5SHOTS: //BS-Aquamentus
1873 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1875 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877
1878 [[fallthrough]];
1879 case e1t3SHOTSFAST:
1880 case e1t3SHOTS: //Aquamentus
1881
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1882 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1883
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1884 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1885
1886 [[fallthrough]];
1887 default:
1888
12/20
✓ Branch 0 taken 43502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43502 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43502 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43502 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 43502 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 43497 times.
✓ Branch 12 taken 43502 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 25264 times.
✓ Branch 16 taken 43502 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 43502 times.
✗ Branch 19 not taken.
43502 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1889 43502 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1890 43502 sfx(wpnsfx(wpn),pan(x));
1891 43502 break;
1892
1893 case e1tSLANT:
1894 {
1895 424 int32_t slant = 0;
1896
1897
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 224 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 153 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
424 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1898 246 slant = left;
1899
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1900 117 slant = right;
1901
1902
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1903 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1904 330 sfx(wpnsfx(wpn),pan(x));
1905 330 break;
1906 }
1907
1908 case e1t8SHOTS: //Fire Wizzrobe
1909
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1910 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1912
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1913 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1915
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1916 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1918
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1919 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1921
1922 [[fallthrough]];
1923 case e1t4SHOTS: //Stalfos 3
1924
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1925 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1927
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1928 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1930
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1931 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1933
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1934 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1936 1937 sfx(wpnsfx(wpn),pan(x));
1937 1937 break;
1938
1939 case e1tSUMMON: // Bat Wizzrobe
1940 {
1941 if(dmisc4==0) break; // Summon 0
1942
1943 int32_t bc=0;
1944
1945 for(int32_t gc=0; gc<guys.Count(); gc++)
1946 {
1947 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1948 {
1949 ++bc;
1950 }
1951 }
1952
1953 if(bc<=40) // Not too many enemies
1954 {
1955 int32_t kids = guys.Count();
1956 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1957
1958 for(int32_t i=0; i<bats; i++)
1959 {
1960 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1961 {
1962 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1963 }
1964 }
1965
1966 sfx(firesfx, pan(x));
1967 }
1968
1969 break;
1970 }
1971
1972 case e1tSUMMONLAYER: // Summoner
1973 {
1974 if(count_layer_enemies(screen_spawned)==0)
1975 {
1976 break;
1977 }
1978
1979 int32_t kids = guys.Count();
1980
1981 if(kids<40)
1982 {
1983 int32_t newguys=(zc_oldrand()%3)+1;
1984 bool summoned=false;
1985
1986 for(int32_t i=0; i<newguys; i++)
1987 {
1988 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1989 int32_t x2=0;
1990 int32_t y2=0;
1991
1992 for(int32_t k=0; k<20; ++k)
1993 {
1994 x2=16*((zc_oldrand()%12)+2);
1995 y2=16*((zc_oldrand()%7)+2);
1996
1997 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1998 {
1999 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2000 {
2001 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2002 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2003 {
2004 ((enemy*)guys.spr(kids+i))->fakez = 64;
2005 ((enemy*)guys.spr(kids+i))->z = 0;
2006 }
2007 }
2008
2009 summoned=true;
2010 break;
2011 }
2012 }
2013 }
2014
2015 if(summoned)
2016 {
2017 sfx(firesfx, pan(x));
2018 }
2019 }
2020
2021 break;
2022 }
2023 }
2024 45900 }
2025
2026
2027 // Hit the shield(s)?
2028 // Apparently, this function is only used for hookshots...
2029 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2030 {
2031
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(type==eeWALK || type==eeFIRE || type==eeOTHER))
2032 834 return false;
2033
2034 1933 bool ret = false;
2035
2036 // TODO: There must be some bitwise operations that can simplify this...
2037
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2038
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2039
2040
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2041
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2042
2043 1933 return ret;
2044 2767 }
2045
2046
2047 //! Weapon Editor for 2.6
2048 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2049
2050
2051 //converts a wqeapon ID to its defence index.
2052 136228 int32_t weaponToDefence(int32_t wid)
2053 {
2054
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 67251 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25184 times.
✓ Branch 4 taken 4409 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3334 times.
✓ Branch 9 taken 10907 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2153 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 486 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 4583 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
136228 switch(wid)
2055 {
2056 case wNone: return -1;
2057 67251 case wSword: return edefSWORD;
2058 9439 case wBeam: return edefBEAM;
2059 25184 case wBrang: return edefBRANG;
2060 4409 case wBomb: return edefBOMB;
2061 37 case wSBomb: return edefSBOMB;
2062 48 case wLitBomb: return edefBOMB;
2063 case wLitSBomb: return edefSBOMB;
2064 3334 case wArrow: return edefARROW;
2065 10907 case wFire: return edefFIRE;
2066 case wWhistle:
2067 {
2068 return edefWhistle;
2069 }
2070 case wBait: return edefBAIT;
2071 269 case wWand: return edefWAND;
2072 1438 case wMagic: return edefMAGIC;
2073 case wCatching: return -1;
2074 case wWind: return edefWIND;
2075 512 case wRefMagic: return edefREFMAGIC;
2076 1459 case wRefFireball: return edefREFBALL;
2077 case wRefRock: return edefREFROCK;
2078 2153 case wHammer: return edefHAMMER;
2079 2767 case wHookshot: return edefHOOKSHOT;
2080 610 case wHSHandle: return edefHOOKSHOT;
2081 case wHSChain: return edefHOOKSHOT;
2082 240 case wSSparkle: return edefSPARKLE;
2083 486 case wFSparkle: return edefSPARKLE;
2084 case wSmack: return -1; // is this the candle object?
2085 case wPhantom: return -1; //engine created visual effects.
2086 case wCByrna: return edefBYRNA;
2087 19 case wRefBeam: return edefREFBEAM;
2088 case wStomp: return edefSTOMP;
2089 4583 case wScript1: return edefSCRIPT01;
2090 case wScript2: return edefSCRIPT02;
2091 12 case wScript3: return edefSCRIPT03;
2092 77 case wScript4: return edefSCRIPT04;
2093 case wScript5: return edefSCRIPT05;
2094 case wScript6: return edefSCRIPT06;
2095 case wScript7: return edefSCRIPT07;
2096 case wScript8: return edefSCRIPT08;
2097 case wScript9: return edefSCRIPT09;
2098 993 case wScript10: return edefSCRIPT10;
2099 case wIce: return edefICE;
2100 case wSound: return edefSONIC;
2101 1 case wThrown: return edefTHROWN;
2102 case wRefArrow: return edefREFARROW;
2103 case wRefFire: return edefREFFIRE;
2104 case wRefFire2: return edefREFFIRE2;
2105 //case wPot: return edefPOT;
2106 // case wLitZap: return edefELECTRIC;
2107 // case wZ3Sword: return edefZ3SWORD;
2108 // case wLASWord: return edefLASWORD;
2109 // case wSpinAttk: return edefSPINATTK;
2110 // case wShield: return edefSHIELD;
2111 // case wTrowel: return edefTROWEL;
2112
2113 default: return -1;
2114 }
2115 136228 }
2116
2117 136228 int32_t getDefType(weapon *w)
2118 {
2119 136228 int32_t id = getWeaponID(w);
2120 136228 int32_t edef = weaponToDefence(id);
2121
2/2
✓ Branch 0 taken 132851 times.
✓ Branch 1 taken 3377 times.
136228 if(edef == edefHOOKSHOT)
2122 {
2123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2124 return edefSwitchHook;
2125 3377 }
2126 136228 return edef;
2127 136228 }
2128
2129 244505 int32_t getWeaponID(weapon *w)
2130 {
2131 244505 int32_t usewpn = w->useweapon;
2132
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 244275 times.
244505 return (usewpn > 0) ? usewpn : w->id;
2133 }
2134
2135 136228 int32_t enemy::resolveEnemyDefence(weapon *w)
2136 {
2137 //sword edef is 9, but we're reading it at 0
2138 //,
2139 136228 int32_t weapondef = 0;
2140 136228 int32_t wdeftype = getDefType(w);
2141 136228 int32_t usedef = w->usedefense;
2142
2143
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 136228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
136228 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2144 {
2145 weapondef = usedef*-1;
2146 }
2147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136228 times.
136228 else if(unsigned(wdeftype) < edefLAST255)
2148 {
2149 136228 weapondef = wdeftype;
2150 136228 }
2151 136228 return weapondef;
2152 }
2153
2154 147104 byte get_def_ignrflag(int32_t edef)
2155 {
2156
3/3
✓ Branch 0 taken 119115 times.
✓ Branch 1 taken 3702 times.
✓ Branch 2 taken 24287 times.
147104 switch(edef)
2157 {
2158 case edIGNORE:
2159 case edIGNOREL1:
2160 case edSTUNORIGNORE:
2161 24287 return WPNUNB_IGNR;
2162 case edSTUNORCHINK:
2163 case edCHINK:
2164 case edCHINKL1:
2165 case edCHINKL2:
2166 case edCHINKL4:
2167 case edCHINKL6:
2168 case edCHINKL8:
2169 case edCHINKL10:
2170 case edLEVELCHINK2:
2171 case edLEVELCHINK3:
2172 case edLEVELCHINK4:
2173 case edLEVELCHINK5:
2174 3702 return WPNUNB_BLOCK;
2175 }
2176 119115 return 0;
2177 147104 }
2178
2179 147104 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2180 {
2181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147104 times.
147104 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2182 switch(edef)
2183 {
2184 case edIGNORE:
2185 case edIGNOREL1:
2186 case edCHINK:
2187 case edCHINKL1:
2188 case edCHINKL2:
2189 case edCHINKL4:
2190 case edCHINKL6:
2191 case edCHINKL8:
2192 case edCHINKL10:
2193 case edLEVELCHINK2:
2194 case edLEVELCHINK3:
2195 case edLEVELCHINK4:
2196 case edLEVELCHINK5:
2197 return edNORMAL;
2198 case edSTUNORIGNORE:
2199 case edSTUNORCHINK:
2200 return edSTUNONLY;
2201 }
2202 return edef;
2203 147104 }
2204
2205 // Do we do damage?
2206 // 0: takehit returns 0
2207 // 1: takehit returns 1
2208 // -1: do damage
2209 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2210 135235 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2211 {
2212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 if(switch_hooked) return 0;
2213 135235 int32_t tempx = x;
2214 135235 int32_t tempy = y;
2215 135235 int32_t the_defence = 0;
2216
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2217 {
2218 the_defence = edef*-1; //A specific defence type.
2219 }
2220 135235 else the_defence = defense[edef];
2221
2222 135235 the_defence = conv_edef_unblockable(the_defence, unblockable);
2223
2224
3/4
✓ Branch 0 taken 6811 times.
✓ Branch 1 taken 128424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6811 times.
135235 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2225 {
2226
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6804 times.
✓ Branch 2 taken 7 times.
6811 switch(the_defence)
2227 {
2228 case edIGNORE:
2229 7 return 0;
2230 case edIGNOREL1:
2231 case edSTUNORIGNORE:
2232 if(*power <= 0)
2233 return 0;
2234 }
2235 6804 sfx(WAV_CHINK,pan(x));
2236 6804 return 1;
2237 }
2238
2239 128424 int32_t new_id = id;
2240 128424 int32_t effect_type = dmisc15;
2241 128424 int32_t delay_timer = 90;
2242 128424 enemy *gleeok = NULL;
2243 128424 enemy *ptra = NULL;
2244 128424 int32_t c = 0;
2245
2246
17/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 525 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1935 times.
✓ Branch 6 taken 1958 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 963 times.
✓ Branch 13 taken 22345 times.
✓ Branch 14 taken 1007 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 497 times.
✓ Branch 23 taken 8 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 181 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 96382 times.
128424 switch(the_defence)
2247 {
2248 case edREPLACE:
2249 {
2250 sclk = 0;
2251 if ( dmisc16 > 0 ) new_id = dmisc16;
2252 else new_id = id+1;
2253 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2254 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2255 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2256
2257 //Z_scripterrlog("new id is %d\n", new_id);
2258 switch(guysbuf[new_id&0xFFF].type)
2259 {
2260 //Fixme: possible enemy memory leak. (minor)
2261 case eeWALK:
2262 {
2263 enemy *e = new eStalfos(x,y,new_id,clk);
2264 guys.add(e);
2265 }
2266 break;
2267
2268 case eeLEV:
2269 {
2270 enemy *e = new eLeever(x,y,new_id,clk);
2271 guys.add(e);
2272 }
2273 break;
2274
2275 case eeTEK:
2276 {
2277 enemy *e = new eTektite(x,y,new_id,clk);
2278 guys.add(e);
2279 }
2280 break;
2281
2282 case eePEAHAT:
2283 {
2284 enemy *e = new ePeahat(x,y,new_id,clk);
2285 guys.add(e);
2286 }
2287 break;
2288
2289 case eeZORA:
2290 {
2291 enemy *e = new eZora(x,y,new_id,clk);
2292 guys.add(e);
2293 }
2294 break;
2295
2296 case eeGHINI:
2297 {
2298 enemy *e = new eGhini(x,y,new_id,clk);
2299 guys.add(e);
2300 }
2301 break;
2302
2303 case eeKEESE:
2304 {
2305 enemy *e = new eKeese(x,y,new_id,clk);
2306 guys.add(e);
2307 }
2308 break;
2309
2310 case eeWIZZ:
2311 {
2312 enemy *e = new eWizzrobe(x,y,new_id,clk);
2313 guys.add(e);
2314 }
2315 break;
2316
2317 case eePROJECTILE:
2318 {
2319 enemy *e = new eProjectile(x,y,new_id,clk);
2320 guys.add(e);
2321 }
2322 break;
2323
2324 case eeWALLM:
2325 {
2326 enemy *e = new eWallM(x,y,new_id,clk);
2327 guys.add(e);
2328 }
2329 break;
2330
2331 case eeAQUA:
2332 {
2333 enemy *e = new eAquamentus(x,y,new_id,clk);
2334 guys.add(e);
2335 e->x = x;
2336 e->y = y;
2337 }
2338 break;
2339
2340 case eeMOLD:
2341 {
2342 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2343 guys.add(e);
2344 e->x = x;
2345 e->y = y;
2346 }
2347 break;
2348
2349 case eeMANHAN:
2350 {
2351 enemy *e = new eManhandla(x,y,new_id,clk);
2352 guys.add(e);
2353 e->x = x;
2354 e->y = y;
2355 }
2356 break;
2357
2358 case eeGLEEOK:
2359 {
2360 *power = 0;
2361 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2362 guys.add(gleeok);
2363 // TODO(crash): check that .add succeeds.
2364 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2365 new_id &= 0xFFF;
2366 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2367 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2368 for(int32_t i=0; i<head_cnt; i++)
2369 {
2370 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2371 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2372 {
2373 al_trace("Gleeok head %d could not be created!\n",i+1);
2374
2375 for(int32_t j=0; j<i+1; j++)
2376 {
2377 guys.del(guys.Count()-1);
2378 }
2379
2380 break;
2381 }
2382 else
2383 {
2384 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2385 }
2386
2387 c-=guysbuf[new_id].attributes[3];
2388 }
2389 return 1;
2390 }
2391
2392 case eeGHOMA:
2393 {
2394 enemy *e = new eGohma(x,y,new_id,clk);
2395 guys.add(e);
2396 e->x = x;
2397 e->y = y;
2398 }
2399 break;
2400
2401 case eeLANM:
2402 {
2403 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2404 guys.add(e);
2405 e->x = x;
2406 e->y = y;
2407 }
2408 break;
2409
2410 case eeGANON:
2411 {
2412 enemy *e = new eGanon(x,y,new_id,clk);
2413 guys.add(e);
2414 e->x = x;
2415 e->y = y;
2416 }
2417 break;
2418
2419 case eeFAIRY:
2420 {
2421 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2422 guys.add(e);
2423 e->x = x;
2424 e->y = y;
2425 }
2426 break;
2427
2428 case eeFIRE:
2429 {
2430 enemy *e = new eFire(x,y,new_id,clk);
2431 guys.add(e);
2432 e->x = x;
2433 e->y = y;
2434 }
2435 break;
2436
2437 case eeOTHER:
2438 {
2439 enemy *e = new eOther(x,y,new_id,clk);
2440 guys.add(e);
2441 e->x = x;
2442 e->y = y;
2443 }
2444 break;
2445
2446 case eeSPINTILE:
2447 {
2448 enemy *e = new eSpinTile(x,y,new_id,clk);
2449 guys.add(e);
2450 e->x = x;
2451 e->y = y;
2452 }
2453 break;
2454
2455 // and these enemies use the misc10/misc2 value
2456 case eeROCK:
2457 {
2458 switch(guysbuf[new_id&0xFFF].attributes[9])
2459 {
2460 case 1:
2461 {
2462 enemy *e = new eBoulder(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 case 0:
2470 default:
2471 {
2472 enemy *e = new eRock(x,y,new_id,clk);
2473 guys.add(e);
2474 e->x = x;
2475 e->y = y;
2476 }
2477 break;
2478 }
2479
2480 break;
2481 }
2482
2483 case eeTRAP:
2484 {
2485 switch(guysbuf[new_id&0xFFF].attributes[1])
2486 {
2487 case 1:
2488 {
2489 enemy *e = new eTrap2(x,y,new_id,clk);
2490 guys.add(e);
2491 e->x = x;
2492 e->y = y;
2493 }
2494 break;
2495
2496 case 0:
2497 default:
2498 {
2499 enemy *e = new eTrap(x,y,new_id,clk);
2500 guys.add(e);
2501 e->x = x;
2502 e->y = y;
2503 }
2504 break;
2505 }
2506
2507 break;
2508 }
2509
2510 case eeDONGO:
2511 {
2512 switch(guysbuf[new_id&0xFFF].attributes[9])
2513 {
2514 case 1:
2515 {
2516 enemy *e = new eDodongo2(x,y,new_id,clk);
2517 guys.add(e);
2518 e->x = x;
2519 e->y = y;
2520 }
2521 break;
2522
2523 case 0:
2524 default:
2525 {
2526 enemy *e = new eDodongo(x,y,new_id,clk);
2527 guys.add(e);
2528 e->x = x;
2529 e->y = y;
2530 }
2531 break;
2532 }
2533
2534 break;
2535 }
2536
2537 case eeDIG:
2538 {
2539 switch(guysbuf[new_id&0xFFF].attributes[9])
2540 {
2541 case 1:
2542 {
2543 enemy *e = new eLilDig(x,y,new_id,clk);
2544 guys.add(e);
2545 e->x = x;
2546 e->y = y;
2547 }
2548 break;
2549
2550 case 0:
2551 default:
2552 {
2553 enemy *e = new eBigDig(x,y,new_id,clk);
2554 guys.add(e);
2555 e->x = x;
2556 e->y = y;
2557 }
2558 break;
2559 }
2560
2561 break;
2562 }
2563
2564 case eePATRA:
2565 {
2566 switch(guysbuf[new_id&0xFFF].attributes[9])
2567 {
2568 case 1:
2569 {
2570 if (get_qr(qr_HARDCODED_BS_PATRA))
2571 {
2572 enemy *e = new ePatraBS(x,y,new_id,clk);
2573 guys.add(e);
2574 e->x = x;
2575 e->y = y;
2576 break;
2577 }
2578 }
2579 [[fallthrough]];
2580 case 0:
2581 default:
2582 {
2583 enemy *e = new ePatra(x,y,new_id,clk);
2584 guys.add(e);
2585 e->x = x;
2586 e->y = y;
2587 }
2588 break;
2589 }
2590
2591 break;
2592 }
2593
2594 case eeGUY:
2595 {
2596 switch(guysbuf[new_id&0xFFF].attributes[9])
2597 {
2598 case 1:
2599 {
2600 enemy *e = new eTrigger(x,y,new_id,clk);
2601 guys.add(e);
2602 }
2603 break;
2604
2605 case 0:
2606 default:
2607 {
2608 enemy *e = new eNPC(x,y,new_id,clk);
2609 guys.add(e);
2610 }
2611 break;
2612 }
2613
2614 break;
2615 }
2616
2617 case eeSCRIPT01:
2618 case eeSCRIPT02:
2619 case eeSCRIPT03:
2620 case eeSCRIPT04:
2621 case eeSCRIPT05:
2622 case eeSCRIPT06:
2623 case eeSCRIPT07:
2624 case eeSCRIPT08:
2625 case eeSCRIPT09:
2626 case eeSCRIPT10:
2627 case eeSCRIPT11:
2628 case eeSCRIPT12:
2629 case eeSCRIPT13:
2630 case eeSCRIPT14:
2631 case eeSCRIPT15:
2632 case eeSCRIPT16:
2633 case eeSCRIPT17:
2634 case eeSCRIPT18:
2635 case eeSCRIPT19:
2636 case eeSCRIPT20:
2637 {
2638 enemy *e = new eScript(x,y,new_id,clk);
2639 guys.add(e);
2640 e->x = x;
2641 e->y = y;
2642 break;
2643 }
2644
2645
2646 case eeFFRIENDLY01:
2647 case eeFFRIENDLY02:
2648 case eeFFRIENDLY03:
2649 case eeFFRIENDLY04:
2650 case eeFFRIENDLY05:
2651 case eeFFRIENDLY06:
2652 case eeFFRIENDLY07:
2653 case eeFFRIENDLY08:
2654 case eeFFRIENDLY09:
2655 case eeFFRIENDLY10:
2656 {
2657 enemy *e = new eFriendly(x,y,new_id,clk);
2658 guys.add(e);
2659 e->x = x;
2660 e->y = y;
2661 break;
2662 }
2663
2664
2665 default: break;
2666 }
2667
2668 // add segments of segmented enemies
2669 int32_t c=0;
2670
2671 switch(guysbuf[new_id&0xFFF].type)
2672 {
2673 case eeMOLD:
2674 {
2675 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2676 new_id &= 0xFFF;
2677
2678 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2679 {
2680 //christ this is messy -DD
2681 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2682
2683 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2684 {
2685 al_trace("Moldorm segment %d could not be created!\n",i+1);
2686
2687 for(int32_t j=0; j<i+1; j++)
2688 guys.del(guys.Count()-1);
2689
2690 return 0;
2691 }
2692
2693 if(i>0)
2694 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2695
2696
2697 }
2698
2699 break;
2700 }
2701
2702 case eeLANM:
2703 {
2704 new_id &= 0xFFF;
2705 int32_t shft = guysbuf[new_id].attributes[1];
2706 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2707 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2708
2709 if(!guys.add(e))
2710 {
2711 al_trace("Lanmola segment 1 could not be created!\n");
2712 guys.del(guys.Count()-1);
2713 return 0;
2714 }
2715 e->x = x;
2716 e->y = y;
2717
2718
2719
2720 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2721 {
2722 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2723 if(!guys.add(e2))
2724 {
2725 al_trace("Lanmola segment %d could not be created!\n",i+1);
2726
2727 for(int32_t j=0; j<i+1; j++)
2728 guys.del(guys.Count()-1);
2729
2730 return 0;
2731 }
2732 e2->x = x;
2733 e2->y = y;
2734
2735 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2736
2737 }
2738 }
2739 break;
2740
2741 case eeMANHAN:
2742 new_id &= 0xFFF;
2743
2744 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2745 {
2746 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2747 {
2748 al_trace("Manhandla head %d could not be created!\n",i+1);
2749
2750 for(int32_t j=0; j<i+1; j++)
2751 {
2752 guys.del(guys.Count()-1);
2753 }
2754
2755 return 0;
2756 }
2757
2758
2759 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2760 }
2761
2762 break;
2763
2764 case eeGLEEOK:
2765 {
2766 /*
2767 new_id &= 0xFFF;
2768 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2769 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2770 for(int32_t i=0; i<head_cnt; i++)
2771 {
2772 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2773 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2774 {
2775 al_trace("Gleeok head %d could not be created!\n",i+1);
2776
2777 for(int32_t j=0; j<i+1; j++)
2778 {
2779 guys.del(guys.Count()-1);
2780 }
2781
2782 break;
2783 }
2784
2785 c-=guysbuf[new_id].misc4;
2786 */
2787
2788 // }
2789 }
2790 break;
2791
2792
2793 case eePATRA:
2794 {
2795 new_id &= 0xFFF;
2796 int32_t outeyes = 0;
2797 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2798
2799 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2800 {
2801 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2802 {
2803 al_trace("Patra outer eye %d could not be created!\n",i+1);
2804
2805 for(int32_t j=0; j<i+1; j++)
2806 guys.del(guys.Count()-1);
2807
2808 return 0;
2809 }
2810 else
2811 outeyes++;
2812
2813
2814 }
2815
2816 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2817 {
2818 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2819 {
2820 al_trace("Patra inner eye %d could not be created!\n",i+1);
2821
2822 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2823 guys.del(guys.Count()-1);
2824
2825 return 0;
2826 }
2827
2828
2829 }
2830 delete ptra;
2831 break;
2832 }
2833 }
2834
2835
2836 // TODO(crash): check that the above .add succeeded.
2837 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2838 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2839 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2840 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2841 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2842 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2843 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2844 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2845 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2846 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2847 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2848 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2849
2850
2851 item_set = 0; //Do not make a drop.
2852
2853 switch(effect_type)
2854 {
2855 case -7:
2856 {
2857 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2858 Lwpns.add(w);
2859 break;
2860 }
2861 case -6:
2862 {
2863 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2864 Lwpns.add(w);
2865 break;
2866 }
2867 case -5:
2868 {
2869 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2870 Lwpns.add(w);
2871 break;
2872 }
2873 case -4:
2874 {
2875 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2876 Lwpns.add(w);
2877 break;
2878 }
2879 case -3: explode(1); break;
2880 case -2: explode(2); break;
2881 case -1: explode(0); break;
2882 case 0: break;
2883
2884 default:
2885 {
2886 //Dummy weapon function
2887 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2888 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2889 Lwpns.add(w);
2890 break;
2891 }
2892 }
2893
2894
2895 yofs = -32768;
2896 switch(guysbuf[new_id&0xFFF].type)
2897 {
2898 case eeGLEEOK:
2899 {
2900 Z_scripterrlog("Replacing a gleeok.\n");
2901 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2902 hp = -999;
2903 if (tempenemy) tempenemy->hp = -999;
2904 break;
2905
2906 }
2907 default:
2908 hp = -1000; break;
2909 }
2910 int mi = mapind(cur_map, screen_spawned);
2911 ++game->guys[mi];
2912 return 1;
2913
2914 }
2915 case edSPLIT:
2916 {
2917 for ( int32_t q = 0; q < dmisc4; q++ )
2918 {
2919 addenemy(screen_spawned,x,y,
2920 dmisc3+0x1000,-15);
2921
2922 }
2923 item_set = 0; //Do not make a drop.
2924 hp = -1000;
2925 return -1;
2926
2927 }
2928 case edSUMMON:
2929 {
2930 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2931 for ( int32_t q = 0; q < summon_count; q++ )
2932 {
2933 int32_t x2=16*((zc_oldrand()%12)+2);
2934 int32_t y2=16*((zc_oldrand()%7)+2);
2935 addenemy(screen_spawned,
2936 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2937 x2,y2,
2938 dmisc3+0x1000,-15);
2939
2940 }
2941 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(x));
2942 return -1;
2943
2944 }
2945
2946 case edEXPLODESMALL:
2947 {
2948 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2949 Ewpns.add(ew);
2950 item_set = 0; //Should we make a drop?
2951 hp = -1000;
2952 return -1;
2953 }
2954
2955
2956 case edEXPLODEHARMLESS:
2957 {
2958 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2959 Ewpns.add(ew);
2960 ew->hyofs = -32768;
2961 item_set = 0; //Should we make a drop?
2962 hp = -1000;
2963 return -1;
2964 }
2965
2966
2967 case edEXPLODELARGE:
2968 {
2969 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2970 Ewpns.add(ew);
2971
2972 hp = -1000;
2973 return -1;
2974 }
2975
2976
2977 case edTRIGGERSECRETS:
2978 {
2979 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2980 return -1;
2981 }
2982
2983 case edSTUNORCHINK:
2984
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2985 {
2986 649 sfx(WAV_CHINK,pan(x));
2987 649 return 1;
2988 }
2989
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2990 {
2991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2992 return 0;
2993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2994 {
2995 sfx(WAV_CHINK,pan(x));
2996 return 1;
2997 }
2998 1119 }
2999 [[fallthrough]];
3000
3001 case edSTUNORIGNORE:
3002
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 2502 times.
3461 if(*power <= 0)
3003 959 return 0;
3004
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3007 return 0;
3008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3009 {
3010 sfx(WAV_CHINK,pan(x));
3011 return 1;
3012 }
3013 1952 }
3014 [[fallthrough]];
3015
3016 case edSTUNONLY:
3017
7/10
✓ Branch 0 taken 4460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3913 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4139 times.
✓ Branch 9 taken 321 times.
4460 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3018 {
3019 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3020 321 return 1;
3021 }
3022
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 3198 times.
4139 if (stunclk)
3023 {
3024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3198 times.
3198 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3025 return 0;
3026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3198 times.
3198 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3027 {
3028 sfx(WAV_CHINK,pan(x));
3029 return 1;
3030 }
3031 3198 }
3032 4139 stunclk=160;
3033 4139 sfx(WAV_EHIT,pan(x));
3034 4139 return 1;
3035
3036 case edCHINKL1:
3037 if(*power >= 1*game->get_hero_dmgmult()) break;
3038 [[fallthrough]];
3039 case edCHINKL2:
3040
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3041 [[fallthrough]];
3042 case edCHINKL4:
3043
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3044 [[fallthrough]];
3045 case edCHINKL6:
3046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3047 [[fallthrough]];
3048 case edCHINKL8:
3049
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3050 [[fallthrough]];
3051 case edCHINKL10:
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3053 [[fallthrough]];
3054 case edCHINK:
3055 1074 sfx(WAV_CHINK,pan(x));
3056 1074 return 1;
3057
3058 case edIGNOREL1:
3059 if(*power > 0) break;
3060 [[fallthrough]];
3061
3062 case edIGNORE:
3063 22345 return 0;
3064
3065 case ed1HKO:
3066 525 *power = hp;
3067 525 return -3;
3068
3069 case ed2x:
3070 {
3071
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 *power = zc_max(1,*power*2);
3072 //int32_t pow = *power;
3073 //*power = vbound((pow*2),0,214747);
3074 497 return -1;
3075 }
3076 case ed3x:
3077 {
3078
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 *power = zc_max(1,*power*3);
3079 //int32_t pow = *power;
3080 //*power = vbound((pow*3),0,214747);
3081 8 return -1;
3082 }
3083
3084 case ed4x:
3085 {
3086 *power = zc_max(1,*power*4);
3087 //int32_t pow = *power;
3088 //*power = vbound((pow*4),0,214747);
3089 return -1;
3090 }
3091
3092
3093 case edHEAL:
3094 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3095 //int32_t pow = *power;
3096 //*power = vbound((pow*-1),0,214747);
3097 //break;
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3099 158 return -1;
3100 }
3101 /*
3102 case edLEVELDAMAGE:
3103 {
3104 int32_t pow = *power;
3105 int32_t lvl = *level;
3106 *power = vbound((pow*lvl),0,214747);
3107 break;
3108 }
3109 case edLEVELREDUCTION:
3110 {
3111 int32_t pow = *power;
3112 int32_t lvl = *level;
3113 *power = vbound((pow/lvl),0,214747);
3114 break;
3115 }
3116 */
3117
3118 case edQUARTDAMAGE:
3119
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 3 times.
181 *power = zc_max(1,*power/2);
3120
3121 [[fallthrough]];
3122 case edHALFDAMAGE:
3123
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 191 times.
1188 *power = zc_max(1,*power/2);
3124 1188 break;
3125
3126 case edSWITCH:
3127 {
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(type)
3130 {
3131 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3132 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3133 return 0;
3134 }
3135 4 hooked_comborpos = rpos_t::None;
3136 4 hooked_layerbits = 0;
3137 4 switching_object = this;
3138 4 switch_hooked = true;
3139 4 Hero.doSwitchHook(game->get_switchhookstyle());
3140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3141 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
3142 4 return 1;
3143 }
3144
3145 case 0:
3146 {
3147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96382 times.
96382 if(edef == edefSwitchHook)
3148 return -1;
3149
4/4
✓ Branch 0 taken 19592 times.
✓ Branch 1 taken 76790 times.
✓ Branch 2 taken 7811 times.
✓ Branch 3 taken 11781 times.
96382 if (stunclk && *power == 0)
3150 {
3151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11781 times.
11781 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3152 return 0;
3153
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11755 times.
11781 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3154 {
3155 26 sfx(WAV_CHINK,pan(x));
3156 26 return 1;
3157 }
3158 11755 }
3159 96356 break;
3160 }
3161 }
3162
3163 97719 return -1;
3164 135235 }
3165
3166 135235 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3167 {
3168
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 int wuid = w?w->getUID():0;
3169
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3170
3171
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if(fakeweap)
3172 Lwpns.add(w);
3173 135235 std::vector<int32_t> &ev = FFCore.eventData;
3174 135235 ev.clear();
3175 135235 ev.push_back(*power*10000);
3176 135235 ev.push_back(edef*10000);
3177 135235 ev.push_back(unblockable*10000);
3178 135235 ev.push_back(wpnId*10000);
3179 135235 ev.push_back(0);
3180 135235 ev.push_back(getUID());
3181 135235 ev.push_back(wuid);
3182
3183 135235 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3184 135235 *power = ev[0]/10000;
3185 135235 edef = ev[1]/10000;
3186 135235 unblockable = byte(ev[2]/10000);
3187 135235 wpnId = ev[3] / 10000;
3188 135235 bool nullify = ev[4]!=0;
3189 135235 ev.clear();
3190 135235 int ret = 0;
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 if(!nullify)
3192 {
3193 135235 ret = defendNew(wpnId, power, edef, unblockable);
3194
2/2
✓ Branch 0 taken 37690 times.
✓ Branch 1 taken 97545 times.
135235 if(ret < 0)
3195 {
3196 97545 ev.push_back(*power*10000);
3197 97545 ev.push_back(edef*10000);
3198 97545 ev.push_back(unblockable*10000);
3199 97545 ev.push_back(wpnId*10000);
3200 97545 ev.push_back(0);
3201 97545 ev.push_back(getUID());
3202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97545 times.
97545 ev.push_back(w?w->getUID():0);
3203
3204 97545 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3205 97545 *power = ev[0]/10000;
3206 97545 nullify = ev[4]!=0;
3207 97545 ev.clear();
3208 97545 }
3209 135235 }
3210
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if(fakeweap)
3211 Lwpns.remove(w);
3212
3213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 return nullify ? 0 : ret;
3214 }
3215
3216 108277 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3217 {
3218
2/2
✓ Branch 0 taken 107700 times.
✓ Branch 1 taken 577 times.
108277 if(!realweap) realweap = w;
3219 108277 int32_t wid = getWeaponID(w);
3220
3221 108277 int32_t edef = resolveEnemyDefence(w);
3222
2/2
✓ Branch 0 taken 14862 times.
✓ Branch 1 taken 93415 times.
108277 if(QHeader.zelda_version > 0x250)
3223 14862 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3224
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3225 {
3226 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3227 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3228 993 return defend(wpnId, power, edefSCRIPT);
3229
3230 case wWhistle:
3231 return -1;
3232
3233 default:
3234 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3235 }
3236 108277 }
3237
3238
3239 // Check defenses without actually acting on them.
3240 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3241 {
3242
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3243 {
3244 case edSTUNONLY:
3245 474 return false;
3246 case edSTUNORCHINK:
3247 case edCHINK:
3248 15409 return unblockable&WPNUNB_BLOCK;
3249 case edSTUNORIGNORE:
3250 case edIGNORE:
3251 11050 return unblockable&WPNUNB_IGNR;
3252
3253 case edIGNOREL1:
3254 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3255 case edCHINKL1:
3256 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3257
3258 case edCHINKL2:
3259 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3260
3261 case edCHINKL4:
3262 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3263
3264 case edCHINKL6:
3265 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3266
3267 case edCHINKL8:
3268 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3269 }
3270
3271 469 return true;
3272 27402 }
3273
3274 // Do we do damage?
3275 // 0: takehit returns 0
3276 // 1: takehit returns 1
3277 // -1: do damage
3278 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3279 {
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3281 {
3282 switch(defense[edef])
3283 {
3284 case edIGNORE:
3285 return 0;
3286 case edIGNOREL1:
3287 case edSTUNORIGNORE:
3288 if(*power <= 0)
3289 return 0;
3290 }
3291
3292 sfx(WAV_CHINK,pan(x));
3293 return 1;
3294 }
3295
3296
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3297 {
3298 case edSTUNORCHINK:
3299 if(*power <= 0)
3300 {
3301 sfx(WAV_CHINK,pan(x));
3302 return 1;
3303 }
3304
3305 [[fallthrough]];
3306 case edSTUNORIGNORE:
3307 if(*power <= 0)
3308 return 0;
3309
3310 [[fallthrough]];
3311 case edSTUNONLY:
3312 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3313 return 1;
3314
3315 stunclk=160;
3316 sfx(WAV_EHIT,pan(x));
3317 return 1;
3318
3319 case edFREEZE:
3320 frozenclock=-1;
3321 //sfx(WAV_FREEZE,pan(x));
3322 return 1;
3323
3324 case edCHINKL1:
3325 if(*power >= 1*game->get_hero_dmgmult()) break;
3326 [[fallthrough]];
3327 case edCHINKL2:
3328 if(*power >= 2*game->get_hero_dmgmult()) break;
3329 [[fallthrough]];
3330 case edCHINKL4:
3331 if(*power >= 4*game->get_hero_dmgmult()) break;
3332 [[fallthrough]];
3333 case edCHINKL6:
3334 if(*power >= 6*game->get_hero_dmgmult()) break;
3335 [[fallthrough]];
3336 case edCHINKL8:
3337 if(*power >= 8*game->get_hero_dmgmult()) break;
3338 [[fallthrough]];
3339 case edCHINKL10:
3340 if(*power >= 10*game->get_hero_dmgmult()) break;
3341 [[fallthrough]];
3342 case edCHINK:
3343 sfx(WAV_CHINK,pan(x));
3344 return 1;
3345 case edTRIGGERSECRETS:
3346 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3347 break;
3348
3349 case edIGNOREL1:
3350 if(*power > 0) break;
3351 [[fallthrough]];
3352 case edIGNORE:
3353 800 return 0;
3354
3355 case ed1HKO:
3356 *power = hp;
3357 return -3;
3358
3359 case ed2x:
3360 {
3361 *power = zc_max(1,*power*2);
3362 //int32_t pow = *power;
3363 //*power = vbound((pow*2),0,214747);
3364 return -1;
3365 }
3366 case ed3x:
3367 {
3368 *power = zc_max(1,*power*3);
3369 //int32_t pow = *power;
3370 //*power = vbound((pow*3),0,214747);
3371 return -1;
3372 }
3373
3374 case ed4x:
3375 {
3376 *power = zc_max(1,*power*4);
3377 //int32_t pow = *power;
3378 //*power = vbound((pow*4),0,214747);
3379 return -1;
3380 }
3381
3382
3383 case edHEAL:
3384 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3385 //int32_t pow = *power;
3386 //*power = vbound((pow*-1),0,214747);
3387 //break;
3388 *power = zc_min(0,*power*-1);
3389 return -1;
3390 }
3391 /*
3392 case edLEVELDAMAGE:
3393 {
3394 int32_t pow = *power;
3395 int32_t lvl = *level;
3396 *power = vbound((pow*lvl),0,214747);
3397 break;
3398 }
3399 case edLEVELREDUCTION:
3400 {
3401 int32_t pow = *power;
3402 int32_t lvl = *level;
3403 *power = vbound((pow/lvl),0,214747);
3404 break;
3405 }
3406 */
3407
3408
3409 case edQUARTDAMAGE:
3410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3411
3412 [[fallthrough]];
3413 case edHALFDAMAGE:
3414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3415 7 break;
3416 }
3417
3418 193 return -1;
3419 993 }
3420
3421 // Defend against a particular item class.
3422 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3423 {
3424 int32_t def=-1;
3425
3426 switch(wpnId)
3427 {
3428 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3429 case wBrang:
3430 def = defend(wpnId, power, edefBRANG);
3431 break;
3432
3433 case wHookshot:
3434 def = defend(wpnId, power, edefHOOKSHOT);
3435 break;
3436
3437 // Anyway...
3438 case wBomb:
3439 def = defend(wpnId, power, edefBOMB);
3440 break;
3441
3442 case wSBomb:
3443 def = defend(wpnId, power, edefSBOMB);
3444 break;
3445
3446 case wArrow:
3447 def = defend(wpnId, power, edefARROW);
3448 break;
3449
3450 case wFire:
3451 def = defend(wpnId, power, edefFIRE);
3452 break;
3453
3454 case wWand:
3455 def = defend(wpnId, power, edefWAND);
3456 break;
3457
3458 case wMagic:
3459 def = defend(wpnId, power, edefMAGIC);
3460 break;
3461
3462 case wHammer:
3463 def = defend(wpnId, power, edefHAMMER);
3464 break;
3465
3466 case wSword:
3467 def = defend(wpnId, power, edefSWORD);
3468 break;
3469
3470 case wBeam:
3471 def = defend(wpnId, power, edefBEAM);
3472 break;
3473
3474 case wRefBeam:
3475 def = defend(wpnId, power, edefREFBEAM);
3476 break;
3477
3478 case wRefMagic:
3479 def = defend(wpnId, power, edefREFMAGIC);
3480 break;
3481
3482 case wRefFireball:
3483 def = defend(wpnId, power, edefREFBALL);
3484 break;
3485
3486 case wRefRock:
3487 def = defend(wpnId, power, edefREFROCK);
3488 break;
3489
3490 case wStomp:
3491 def = defend(wpnId, power, edefSTOMP);
3492 break;
3493
3494 case wCByrna:
3495 def = defend(wpnId, power, edefBYRNA);
3496 break;
3497
3498 case wScript1:
3499 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3500 else def = defend(wpnId, power, edefSCRIPT);
3501 break;
3502
3503 case wScript2:
3504 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3505 else def = defend(wpnId, power, edefSCRIPT);
3506 break;
3507
3508 case wScript3:
3509 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3510 else def = defend(wpnId, power, edefSCRIPT);
3511 break;
3512
3513 case wScript4:
3514 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3515 else def = defend(wpnId, power, edefSCRIPT);
3516 break;
3517
3518 case wScript5:
3519 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3520 else def = defend(wpnId, power, edefSCRIPT);
3521 break;
3522
3523 case wScript6:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wScript7:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript8:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript9:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript10:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wWhistle:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3550 else break;
3551 break;
3552
3553 case wRefArrow:
3554 def = defend(wpnId, power, edefREFARROW);
3555 break;
3556 case wRefFire:
3557 def = defend(wpnId, power, edefREFFIRE);
3558 break;
3559 case wRefFire2:
3560 def = defend(wpnId, power, edefREFFIRE2);
3561 break;
3562
3563 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3564 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3565 //of the ten if the quest version is lower than N.
3566 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3567 //such as bool UseSeparatedScriptDefences. hah.
3568 default:
3569 //if(wpnId>=wScript1 && wpnId<=wScript10)
3570 // {
3571 // def = defend(wpnId, power, edefSCRIPT);
3572 // }
3573 // }
3574
3575 break;
3576 }
3577
3578 return def;
3579 }
3580
3581 // take damage or ignore it
3582 // 2 or -2: force wait a frame
3583 // < 0: damage (if any) dealt
3584 // > 0: blocked
3585 // 0: weapon passes through unhindered
3586 274677 int32_t enemy::takehit(weapon *w, weapon* realweap)
3587 {
3588
2/4
✓ Branch 0 taken 274677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 274677 times.
274677 if(fallclk||drownclk) return 0;
3589
2/2
✓ Branch 0 taken 72352 times.
✓ Branch 1 taken 202325 times.
274677 if(!realweap) realweap = w;
3590 274677 int32_t wpnId = w->id;
3591 274677 int32_t power = w->power;
3592 274677 int32_t wpnx = w->x;
3593 274677 int32_t wpny = w->y;
3594 274677 int32_t enemyHitWeapon = w->parentitem;
3595 int32_t wpnDir;
3596 274677 int32_t parent_item = w->parentitem;
3597
3598
2/2
✓ Branch 0 taken 274562 times.
✓ Branch 1 taken 115 times.
274677 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3599 {
3600 115 wpnId = w->useweapon;
3601 115 }
3602
3603 // If it's a boomerang that just bounced, use the opposite direction;
3604 // otherwise, it might bypass a shield. This probably won't handle
3605 // every case correctly, but it's better than having shields simply
3606 // not work against boomerangs.
3607
8/8
✓ Branch 0 taken 25236 times.
✓ Branch 1 taken 249441 times.
✓ Branch 2 taken 15681 times.
✓ Branch 3 taken 9555 times.
✓ Branch 4 taken 14419 times.
✓ Branch 5 taken 1262 times.
✓ Branch 6 taken 3308 times.
✓ Branch 7 taken 11111 times.
274677 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3608 11111 wpnDir = oppositeDir[w->dir];
3609 else
3610 263566 wpnDir = w->dir;
3611
3612
5/8
✓ Branch 0 taken 274677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 274677 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 274677 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7320 times.
✓ Branch 7 taken 281997 times.
274677 if(dying || clk<0 || hclk>0 || superman)
3613 7320 return 0;
3614
3615 //Prevent boomerang from writing to hitby[] for more than one frame.
3616 //This also prevents stunlock.
3617 //if ( stunclk > 0 ) return 0;
3618 //this needs a rule for boomerangs that cannot stunlock!
3619 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3620 //sigh.
3621
3622 281997 int32_t ret = -1;
3623
3624 // This obscure quest rule...
3625
5/6
✓ Branch 0 taken 101723 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 98021 times.
✓ Branch 3 taken 3702 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98021 times.
281997 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3626 {
3627 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3628 3702 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3629 3702 wpnDir=zc_oldrand()&3;
3630
3631
4/4
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 3209 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 200 times.
3702 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3632 {
3633 200 wpnDir=down;
3634 200 }
3635
4/4
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 2904 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 305 times.
3502 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3636 {
3637 305 wpnDir=right;
3638 305 }
3639
4/4
✓ Branch 0 taken 2487 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 2194 times.
3197 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3640 {
3641 2194 wpnDir=up;
3642 2194 }
3643 else
3644 {
3645 1003 wpnDir=left;
3646 }
3647 3702 }
3648
3649 281997 int32_t xdir = dir;
3650 281997 shieldCanBlock=false;
3651
3652
4/4
✓ Branch 0 taken 270717 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 267950 times.
282759 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3653
6/6
✓ Branch 0 taken 18734 times.
✓ Branch 1 taken 15967 times.
✓ Branch 2 taken 26888 times.
✓ Branch 3 taken 257029 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 256921 times.
270717 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3654
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 255902 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 255140 times.
256921 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3655 )
3656 // The hammer should already be dealt with by subclasses (Walker etc.)
3657 {
3658
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 5961 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 169 times.
✓ Branch 9 taken 1490 times.
47511 switch(wpnId)
3659 {
3660 // Weapons which shields protect against
3661 case wSword:
3662 case wWand:
3663
2/2
✓ Branch 0 taken 5959 times.
✓ Branch 1 taken 2 times.
5963 if(Hero.getCharging()>0)
3664 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3665
3666 [[fallthrough]];
3667 case wHookshot:
3668 case wHSHandle:
3669 case wBrang:
3670 6341 shieldCanBlock=true;
3671 6679 break;
3672
3673 case wBeam:
3674 case wRefBeam:
3675 // Mirror shielded enemies!
3676 #if 0
3677 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3678 {
3679 if(wpnId>wEnemyWeapons)
3680 return 0;
3681
3682 sfx(WAV_CHINK,pan(x));
3683 return 1;
3684 }
3685
3686 #endif
3687
3688 [[fallthrough]];
3689 case wRefRock:
3690 case wRefFireball:
3691 case wMagic:
3692 #if 0
3693 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3694 {
3695 sfx(WAV_CHINK,pan(x));
3696 return 3;
3697 }
3698
3699 #endif
3700
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3702 return 0;
3703
3704 [[fallthrough]];
3705 case wArrow:
3706 411 case wRefArrow:
3707 default:
3708 1901 shieldCanBlock=true;
3709 1901 break;
3710
3711 // Bombs
3712 case wSBomb:
3713 case wBomb:
3714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3715 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3716 {
3717 sfx(WAV_CHINK,pan(x));
3718 return 0;
3719 }
3720 else break;
3721
3722 // Weapons which ignore shields
3723 case wWhistle:
3724 case wHammer:
3725 169 break;
3726
3727 // Weapons which shouldn't be removed by shields
3728 case wLitBomb:
3729 case wLitSBomb:
3730 case wWind:
3731 case wPhantom:
3732 case wSSparkle:
3733 case wBait:
3734 864 return 0;
3735
3736 case wFire:
3737 case wRefFire:
3738 case wRefFire2:
3739 ;
3740 757 }
3741 9168 }
3742
3743
8/8
✓ Branch 0 taken 103856 times.
✓ Branch 1 taken 106603 times.
✓ Branch 2 taken 432 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27419 times.
✓ Branch 5 taken 25184 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9057 times.
275588 switch(wpnId)
3744 {
3745 case wWhistle: //No longer completely ignore whistle weapons! -Z
3746 {
3747
3748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
432 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3749 {
3750 432 return 0; break;
3751 }
3752 else
3753 {
3754 w->power = power = itemsbuf[parent_item].misc5;
3755
3756 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3757
3758 if(def <= 0)
3759 {
3760 hp -= power;
3761 return def;
3762 }
3763 break;
3764 }
3765 break;
3766 }
3767
3768 case wPhantom:
3769 270 return 0;
3770
3771 case wLitBomb:
3772 case wLitSBomb:
3773 case wBait:
3774 case wWind:
3775 case wSSparkle:
3776 103856 return 0;
3777
3778 case wFSparkle:
3779
3780 // Only take sparkle damage if the sparkle's parent item is not
3781 // defended against.
3782
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 27402 times.
27419 if(enemyHitWeapon > -1)
3783 {
3784 27402 int32_t p = 0;
3785 27402 int32_t f = itemsbuf[enemyHitWeapon].type;
3786
3787
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3788 {
3789 case itype_arrow:
3790 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3791
3792 break;
3793
3794 case itype_cbyrna:
3795 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3796
3797 break;
3798
3799 case itype_brang:
3800
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3801
3802 469 break;
3803
3804 default:
3805 return 0;
3806 }
3807 469 }
3808
3809 486 wpnId = wSword;
3810 486 power = game->get_hero_dmgmult()>>1;
3811 486 goto fsparkle;
3812 break;
3813
3814 case wBrang:
3815 {
3816 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3817 25184 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3818 //preventing stunlock might be best, here. -Z
3819
2/2
✓ Branch 0 taken 5585 times.
✓ Branch 1 taken 19599 times.
25184 if(def >= 0) return def;
3820 19599 ret = def;
3821
3822 // Not hurt by 0-damage weapons
3823
2/2
✓ Branch 0 taken 3217 times.
✓ Branch 1 taken 16382 times.
19599 if(!(flags & guy_bhit))
3824 {
3825 16382 stunclk=160;
3826
3827
3/4
✓ Branch 0 taken 16382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15071 times.
16382 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3828 {
3829
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3830 1311 goto hitclock;
3831 }
3832
3833 15071 break;
3834 }
3835
3836
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 2793 times.
3217 if(!power)
3837
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_brang))*game->get_hero_dmgmult();
3838 else
3839 424 hp-=power;
3840
3841 3217 goto hitclock;
3842 }
3843
3844 case wHookshot:
3845 {
3846 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3847 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3848
3849
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3850 1773 ret = def;
3851
3852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3853
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3854 {
3855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3856 1625 stunclk=160;
3857
3858
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3859 {
3860
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3861 549 goto hitclock;
3862 }
3863
3864 1076 break;
3865 }
3866
3867
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_hookshot))*game->get_hero_dmgmult();
3868 else
3869 45 hp-=power;
3870
3871 148 goto hitclock;
3872 }
3873 break;
3874
3875 case wHSHandle:
3876 {
3877
3/4
✓ Branch 0 taken 9057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8534 times.
9057 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3878 523 return 0;
3879
3880
3/4
✓ Branch 0 taken 6094 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8534 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3882
3883 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3884
6/8
✓ Branch 0 taken 2788 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2788 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2788 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2286 times.
10246 if(!(type==eePEAHAT || type==eeAQUA || type==eeMANHAN || (type==eeWIZZ && !ignorehookshot)
3885
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3890 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2178 times.
2788 || (type==eeWALK && dmisc9==e9tPOLSVOICE) || (type==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3886 2178 return 0;
3887
3888 12102 power = game->get_hero_dmgmult();
3889 12588 }
3890
3891 fsparkle:
3892
3893 [[fallthrough]];
3894 default:
3895 // Work out the defenses!
3896 {
3897 107699 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3898
3899
2/2
✓ Branch 0 taken 31754 times.
✓ Branch 1 taken 75945 times.
107699 if(def >= 0)
3900 31754 return def;
3901
2/2
✓ Branch 0 taken 75485 times.
✓ Branch 1 taken 460 times.
75945 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3902 460 ret = 0;
3903 }
3904
3905
2/2
✓ Branch 0 taken 75928 times.
✓ Branch 1 taken 17 times.
151875 if(!power)
3906 {
3907
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 15 times.
17 if(flags & guy_bhit)
3908 2 hp-=1;
3909 else
3910 {
3911 // Don't make a long chain of 'stun' hits
3912
5/8
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 11 times.
15 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3913 4 return 1;
3914
3915
3916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!switch_hooked)
3917 11 stunclk=160;
3918 11 break;
3919 }
3920 2 }
3921 75928 else hp-=power;
3922
3923 hitclock:
3924 81166 hclk=33;
3925
3926 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3927
2/2
✓ Branch 0 taken 36106 times.
✓ Branch 1 taken 45060 times.
81166 if((dir&2)==(w->dir&2))
3928 {
3929 45060 sclk=(w->dir<<8)+16;
3930 45060 }
3931 81166 }
3932
3933
5/6
✓ Branch 0 taken 77725 times.
✓ Branch 1 taken 19599 times.
✓ Branch 2 taken 22015 times.
✓ Branch 3 taken 75309 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22015 times.
97324 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3934 {
3935 22015 fading=fade_blue_poof;
3936 22015 }
3937
3938
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 8722 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
97324 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3939 {
3940
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if( hitsfx > 0 ) //user-set hit sound.
3941 {
3942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if (!dying) //don't play the hit sound on death! -Z
3943 11069 sfx(hitsfx, pan(x));
3944 11069 }
3945 else sfx(WAV_EHIT, pan(x)); //Don't play the hardcoded sound if the user sets a custom one.
3946 11069 }
3947 else //2.50.2 or earlier
3948 {
3949 86255 sfx(WAV_EHIT, pan(x));
3950 86255 sfx(hitsfx, pan(x));
3951 }
3952
2/2
✓ Branch 0 taken 97295 times.
✓ Branch 1 taken 29 times.
97324 if(type==eeGUY)
3953 29 sfx(WAV_EDEAD, pan(x));
3954
3955 // Penetrating weapons
3956
4/4
✓ Branch 0 taken 95310 times.
✓ Branch 1 taken 2014 times.
✓ Branch 2 taken 88404 times.
✓ Branch 3 taken 8920 times.
97324 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3957 {
3958 8920 int32_t item=enemyHitWeapon;
3959
3960
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 7168 times.
8920 if(wpnId==wArrow)
3961 {
3962 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3963
5/6
✓ Branch 0 taken 1624 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1752 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].type == itype_arrow))
3964 379 return 0;
3965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1373 times.
1373 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3966 //if(item<0)
3967 else
3968 1373 item=current_item_id(itype_arrow);
3969 1373 }
3970
3971 else
3972 {
3973
3974 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3975
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].type == itype_sword))
3976 return 0;
3977
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3979 else
3980 //if(item<0)
3981 7168 item=current_item_id(itype_sword);
3982 }
3983 8541 }
3984
3985 96945 return ret;
3986 278037 }
3987
3988 63955692 bool enemy::dont_draw() const
3989 {
3990
6/6
✓ Branch 0 taken 63491179 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 63420272 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175068 times.
✓ Branch 5 taken 63316111 times.
63955692 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3991 639581 return true;
3992
3993
2/2
✓ Branch 0 taken 1375509 times.
✓ Branch 1 taken 61940602 times.
63316111 if(flags&guy_invisible)
3994 1375509 return true;
3995
3996
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 61940170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
61940602 if(flags&guy_lens_only && !lensclk)
3997 return true;
3998
3999 61940602 return false;
4000 63955692 }
4001
4002 #define DRAW_NORMAL 2
4003 #define DRAW_CLOAKED 1
4004 #define DRAW_INVIS 0
4005 // base drawing function to be used by all derived classes instead of
4006 // sprite::draw()
4007 46383919 void enemy::draw(BITMAP *dest)
4008 {
4009 46383919 didScriptThisFrame = false; //Since there's no better place to put it
4010
6/6
✓ Branch 0 taken 45618787 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 45536137 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317591 times.
✓ Branch 5 taken 45301196 times.
46383919 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4011 1082723 return;
4012
2/2
✓ Branch 0 taken 2770966 times.
✓ Branch 1 taken 42530230 times.
45301196 if(flags&guy_invisible)
4013 2770966 return;
4014
4015 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4016 // be cloaked if they have "invisible displays as cloaked" checked.
4017
4018 42530230 byte canSee = DRAW_NORMAL;
4019 //Enemy specific stuff
4020
2/2
✓ Branch 0 taken 42529066 times.
✓ Branch 1 taken 1164 times.
42530230 if ( editorflags & ENEMY_FLAG1 )
4021 {
4022 1164 canSee = DRAW_INVIS;
4023
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4024
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4025 {
4026 if (game->item[dmisc13])
4027 {
4028 canSee = DRAW_NORMAL;
4029 }
4030 //else if ( lensclk && getlensid.flags SHOWINVIS )
4031 //{
4032 //
4033 //}
4034 //else
4035 //{
4036 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4037 // //otherwisem invisible
4038 //}
4039 }
4040 1164 }
4041 //Room specific
4042 42530230 mapscr* scr = get_scr(screen_spawned);
4043
2/2
✓ Branch 0 taken 40359031 times.
✓ Branch 1 taken 2171199 times.
42530230 if (scr->flags3&fINVISROOM)
4044 {
4045
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && type!=eeGANON) canSee = DRAW_CLOAKED;
4047 2171199 }
4048 //Lens check
4049
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 42502693 times.
42530230 if (lensclk)
4050 {
4051
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4052 {
4053
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4054 432 }
4055 27537 }
4056 else
4057 {
4058
2/2
✓ Branch 0 taken 42429277 times.
✓ Branch 1 taken 73416 times.
42502693 if(flags&guy_lens_only)
4059 73416 canSee = DRAW_INVIS;
4060 }
4061
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 42455650 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
42530230 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4062
3/4
✓ Branch 0 taken 42229646 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 42229646 times.
✗ Branch 3 not taken.
42530230 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4063
4064
2/2
✓ Branch 0 taken 42455650 times.
✓ Branch 1 taken 74580 times.
42530230 if (canSee == DRAW_INVIS)
4065 74580 return;
4066
4067
4/4
✓ Branch 0 taken 42452423 times.
✓ Branch 1 taken 3227 times.
✓ Branch 2 taken 1416 times.
✓ Branch 3 taken 42451007 times.
42455650 if(fallclk||drownclk)
4068 {
4069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4643 times.
4643 if (canSee == DRAW_CLOAKED)
4070 {
4071 sprite::drawcloaked(dest);
4072 }
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4643 times.
4643 else if (canSee == DRAW_NORMAL)
4074 {
4075 4643 sprite::draw(dest);
4076 4643 }
4077 4643 return;
4078 }
4079 42451007 int32_t cshold=cs;
4080
4081
2/2
✓ Branch 0 taken 945772 times.
✓ Branch 1 taken 41505235 times.
42451007 if(dying)
4082 {
4083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945772 times.
945772 if(clk2>=19)
4084 {
4085 if(!(clk2&2))
4086 {
4087 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4088 if (canSee == DRAW_CLOAKED)
4089 {
4090 sprite::drawcloaked(dest);
4091 }
4092 else if (canSee == DRAW_NORMAL)
4093 {
4094 sprite::draw(dest);
4095 }
4096 }
4097 return;
4098 }
4099
4100 945772 flip = 0;
4101 945772 tile = wpnsbuf[spr_death].tile;
4102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945772 times.
945772 if ( do_animation )
4103 {
4104 945772 int32_t offs = 0;
4105
2/2
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 92660 times.
945772 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4106 {
4107
2/2
✓ Branch 0 taken 89665 times.
✓ Branch 1 taken 2995 times.
92660 if(clk2 > 2)
4108 {
4109 2995 spr_death_anim_clk=0;
4110 2995 clk2=1;
4111
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2978 times.
2995 if(hp > -1000)
4112 2978 death_sfx();
4113 2995 }
4114
4/4
✓ Branch 0 taken 66415 times.
✓ Branch 1 taken 26245 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 65339 times.
92660 if(clk2==1 && spr_death_anim_clk>-1)
4115 {
4116 65339 ++clk2;
4117
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 62957 times.
65339 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4118
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 65194 times.
65339 spr_death_anim_frm *= zc_max(1,txsz);
4119 65339 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4120
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 65239 times.
65339 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4121
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 62957 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 65337 times.
✓ Branch 4 taken 62370 times.
✓ Branch 5 taken 2969 times.
65339 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4122 {
4123 2969 spr_death_anim_clk=-1;
4124 2969 clk2=1;
4125 2969 }
4126 65339 }
4127 92660 tile += spr_death_anim_frm;
4128 92660 }
4129
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537505 times.
853112 else if(BSZ)
4130 {
4131
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4132 315607 }
4133
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4134 {
4135 179336 offs = 1;
4136 179336 }
4137
4138
2/2
✓ Branch 0 taken 497279 times.
✓ Branch 1 taken 448493 times.
945772 if(offs)
4139 {
4140
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448043 times.
448493 offs *= zc_max(1,txsz);
4141 448493 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4142
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448055 times.
448493 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4143 448493 }
4144 945772 tile += offs;
4145 945772 }
4146
4147
6/6
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 92660 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
945772 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4148 597449 cs = wpnsbuf[spr_death].csets&15;
4149 else
4150 348323 cs = (((clk2+5)>>1)&3)+6;
4151 945772 }
4152
3/4
✓ Branch 0 taken 1275681 times.
✓ Branch 1 taken 40229554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1275681 times.
41505235 else if(hclk>0 && getCanFlicker())
4153 {
4154 1275681 cs = getFlashingCSet();
4155 1275681 }
4156 //draw every other frame for flickering enemies
4157
2/2
✓ Branch 0 taken 304540 times.
✓ Branch 1 taken 42146467 times.
42451007 if (is_hitflickerframe(false))
4158 {
4159
5/6
✓ Branch 0 taken 111978 times.
✓ Branch 1 taken 192562 times.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 111881 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 192659 times.
304540 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4160
3/4
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 56509 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
304540 if (game->get_spriteflickercolor() || temp_flicker_color)
4161 {
4162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56509 times.
56509 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4163 56509 sprite_flicker_color = temp_flicker_color;
4164 56509 sprite::draw(dest);
4165 56509 }
4166 304540 }
4167 else
4168 {
4169
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 41921305 times.
42146467 if (canSee == DRAW_CLOAKED)
4170 {
4171 225162 sprite::drawcloaked(dest);
4172 225162 }
4173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41921305 times.
41921305 else if (canSee == DRAW_NORMAL)
4174 {
4175
1/2
✓ Branch 0 taken 41921305 times.
✗ Branch 1 not taken.
41921305 if ( frozenclock < 0 )
4176 {
4177 if ( frozentile > 0 ) tile = frozentile;
4178 loadpalset(csBOSS,frozencset);
4179 }
4180 41921305 sprite::draw(dest);
4181 41921305 }
4182 }
4183 42451007 cs=cshold;
4184 46383919 }
4185
4186 //old zc bosses
4187 40956281 void enemy::drawzcboss(BITMAP *dest)
4188 {
4189 40956281 didScriptThisFrame = false; //Since there's no better place to put it
4190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40956281 times.
40956281 if(dont_draw())
4191 return;
4192
4193 40956281 int32_t cshold=cs;
4194
4195
2/2
✓ Branch 0 taken 784546 times.
✓ Branch 1 taken 40171735 times.
40956281 if(dying)
4196 {
4197
2/2
✓ Branch 0 taken 4248 times.
✓ Branch 1 taken 780298 times.
784546 if(clk2>=19)
4198 {
4199
2/2
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 2124 times.
4248 if(!(clk2&2))
4200 2124 sprite::drawzcboss(dest);
4201
4202 4248 return;
4203 }
4204
4205 780298 flip = 0;
4206 780298 tile = wpnsbuf[spr_death].tile;
4207
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780298 times.
780298 if ( do_animation )
4209 {
4210
2/2
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4736 times.
780298 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4211 {
4212
2/2
✓ Branch 0 taken 4724 times.
✓ Branch 1 taken 12 times.
4736 if(clk2 > 2)
4213 {
4214 12 spr_death_anim_clk=0;
4215 12 clk2=1;
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(hp > -1000)
4217 12 death_sfx();
4218 12 }
4219
4/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 4351 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 196 times.
4736 if(clk2==1 && spr_death_anim_clk>-1)
4220 {
4221 196 ++clk2;
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm *= zc_max(1,txsz);
4224 196 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4226
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
✓ Branch 4 taken 188 times.
✓ Branch 5 taken 8 times.
196 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4227 {
4228 8 spr_death_anim_clk=-1;
4229 8 clk2=1;
4230 8 }
4231 196 }
4232 4736 tile += spr_death_anim_frm;
4233 4736 }
4234
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496976 times.
775562 else if(BSZ)
4235
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4236
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4237 165743 ++tile;
4238 780298 }
4239
4240
6/6
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4736 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
780298 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4241 467194 cs = wpnsbuf[spr_death].csets&15;
4242 else
4243 313104 cs = (((clk2+5)>>1)&3)+6;
4244 780298 }
4245
2/2
✓ Branch 0 taken 38957045 times.
✓ Branch 1 taken 1214690 times.
40171735 else if(hclk>0)
4246 {
4247 1214690 cs = getFlashingCSet();
4248 1214690 }
4249
4250 40952033 mapscr* scr = get_scr(screen_spawned);
4251
4252
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38906414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40959576 if((scr->flags3&fINVISROOM) &&
4253
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4255 7543 lensclk) && type!=eeGANON)
4256 {
4257 7543 sprite::drawcloaked(dest);
4258 7543 }
4259 else
4260 {
4261
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40921017 times.
40944490 if (is_hitflickerframe(true))
4262 {
4263
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4264
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4265 {
4266 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4267 sprite_flicker_color = temp_flicker_color;
4268 sprite::drawzcboss(dest);
4269 }
4270 23473 }
4271 else
4272 40921017 sprite::drawzcboss(dest);
4273 }
4274
4275 40952033 cs=cshold;
4276 40956281 }
4277
4278
4279 // similar to the overblock function--can do up to a 32x32 sprite
4280 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4281 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4282 {
4283 323235 int32_t thold=tile;
4284 323235 int32_t t1=tile;
4285 323235 int32_t t2=tile+20;
4286 323235 int32_t t3=tile+1;
4287 323235 int32_t t4=tile+21;
4288
4289
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4290 {
4291 case 1:
4292 enemy::drawzcboss(dest);
4293 break;
4294
4295 case 3:
4296 if(flip&2)
4297 zc_swap(t1,t2);
4298
4299 tile=t1;
4300 enemy::drawzcboss(dest);
4301 tile=t2;
4302 yofs+=16;
4303 enemy::drawzcboss(dest);
4304 yofs-=16;
4305 break;
4306
4307 case 5:
4308 t2=tile+1;
4309
4310 if(flip&1)
4311 zc_swap(t1,t2);
4312
4313 tile=t1;
4314 enemy::drawzcboss(dest);
4315 tile=t2;
4316 xofs+=16;
4317 enemy::drawzcboss(dest);
4318 xofs-=16;
4319 break;
4320
4321 case 15:
4322
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4323 {
4324 6756 zc_swap(t1,t3);
4325 6756 zc_swap(t2,t4);
4326 6756 }
4327
4328
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4329 {
4330 zc_swap(t1,t2);
4331 zc_swap(t3,t4);
4332 }
4333
4334 323235 tile=t1;
4335 323235 enemy::drawzcboss(dest);
4336 323235 tile=t2;
4337 323235 yofs+=16;
4338 323235 enemy::drawzcboss(dest);
4339 323235 yofs-=16;
4340 323235 tile=t3;
4341 323235 xofs+=16;
4342 323235 enemy::drawzcboss(dest);
4343 323235 tile=t4;
4344 323235 yofs+=16;
4345 323235 enemy::drawzcboss(dest);
4346 323235 xofs-=16;
4347 323235 yofs-=16;
4348 323235 break;
4349 }
4350
4351 323235 tile=thold;
4352 323235 }
4353
4354 22435586 bool enemy::can_drawshadow() const
4355 {
4356
4/4
✓ Branch 0 taken 20420496 times.
✓ Branch 1 taken 2015090 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 19893578 times.
22435586 if(dont_draw() || isSideViewGravity())
4357 2542008 return false;
4358
4359
2/2
✓ Branch 0 taken 356303 times.
✓ Branch 1 taken 19537275 times.
19893578 if(dying)
4360 356303 return false;
4361
4362 19537275 mapscr* scr = get_scr(screen_spawned);
4363
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 17819026 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 19190265 times.
19537275 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4364 19537275 (darkroom))
4365 347010 return false;
4366
4367
6/6
✓ Branch 0 taken 17381648 times.
✓ Branch 1 taken 1808617 times.
✓ Branch 2 taken 17107109 times.
✓ Branch 3 taken 274539 times.
✓ Branch 4 taken 16507954 times.
✓ Branch 5 taken 599155 times.
19190265 if(z <= 0 && fakez <= 0 && enemycanfall(id, false))
4368 16507954 return false;
4369
4370
2/2
✓ Branch 0 taken 21605 times.
✓ Branch 1 taken 2660706 times.
2682311 if(shadow_overpit())
4371 21605 return false;
4372
4373 2660706 return true;
4374 22435586 }
4375 19059922 void enemy::drawshadow(BITMAP *dest, bool translucent)
4376 {
4377
2/2
✓ Branch 0 taken 17351358 times.
✓ Branch 1 taken 1708564 times.
19059922 if(!can_drawshadow())
4378 17351358 return;
4379
4/4
✓ Branch 0 taken 1109409 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 847 times.
✓ Branch 3 taken 1108562 times.
1708564 if(enemycanfall(id, false) && shadowtile == 0)
4380 847 shadowtile = wpnsbuf[spr_shadow].tile;
4381
4382 1708564 sprite::drawshadow(dest,translucent);
4383 19059922 }
4384
4385 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4386 {
4387 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4388
4389
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4390 {
4391 129181 xofs-=mx;
4392 129181 yofs-=my;
4393 129181 enemy::draw(sub);
4394 129181 xofs+=mx;
4395 129181 yofs+=my;
4396 129181 destroy_bitmap(sub);
4397 129181 }
4398 else
4399 enemy::draw(dest);
4400 129181 }
4401
4402 39 void enemy::init_size_flags()
4403 {
4404
3/6
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
39 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4405
4/6
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 16 times.
39 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4406
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
39 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4407
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
39 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4408
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
39 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4409
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4410
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4411
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4412
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4413 {
4414 2 yofs = (int32_t)d->yofs;
4415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4416 2 }
4417
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4418 39 }
4419
4420 // override hit detection to check for invicibility, stunned, etc
4421 118330101 bool enemy::hit()
4422 {
4423
4/4
✓ Branch 0 taken 116852909 times.
✓ Branch 1 taken 1477192 times.
✓ Branch 2 taken 114667209 times.
✓ Branch 3 taken 2185700 times.
118330101 if(dying || hclk>0) return false;
4424 114667209 return sprite::hit();
4425 118330101 }
4426 730351 bool enemy::hit(sprite *s)
4427 {
4428
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4429 713374 return sprite::hit(s);
4430 730351 }
4431
4432 45797464 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4433 {
4434
2/2
✓ Branch 0 taken 4116804 times.
✓ Branch 1 taken 41680660 times.
45797464 if(!hit()) return false;
4435 41680660 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4436 45797464 }
4437 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4438 {
4439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4440 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4441 78011 }
4442
4443 14262185 bool enemy::hit(weapon *w)
4444 {
4445
2/2
✓ Branch 0 taken 1734411 times.
✓ Branch 1 taken 12527774 times.
14262185 if(!hit()) return false;
4446
4447
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 5880392 times.
12527774 if (replay_version_check(0, 14))
4448 {
4449
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4450 225051 return false;
4451 6422331 return sprite::hit(w);
4452 }
4453 5880392 return w->hit(this);
4454 14262185 }
4455
4456 39141797 bool enemy::can_pitfall(bool checkspawning)
4457 {
4458
4/4
✓ Branch 0 taken 37562467 times.
✓ Branch 1 taken 1579330 times.
✓ Branch 2 taken 37541718 times.
✓ Branch 3 taken 1600079 times.
39141797 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4459
2/2
✓ Branch 0 taken 30861954 times.
✓ Branch 1 taken 6679764 times.
37541718 switch(guysbuf[id&0xFFF].type)
4460 {
4461 case eeAQUA:
4462 case eeDIG:
4463 case eeDONGO:
4464 case eeFAIRY:
4465 case eeGANON:
4466 case eeGHOMA:
4467 case eeGLEEOK:
4468 case eeGUY:
4469 case eeLANM:
4470 case eeMANHAN:
4471 case eeMOLD:
4472 case eeNONE:
4473 case eePATRA:
4474 case eeZORA:
4475 6679764 return false; //Disallowed types
4476 default:
4477 30861954 return true;
4478 }
4479 39141797 }
4480 //Handle death
4481 39022651 void enemy::try_death(bool force_kill)
4482 {
4483
8/8
✓ Branch 0 taken 38964550 times.
✓ Branch 1 taken 58101 times.
✓ Branch 2 taken 38964506 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 46559 times.
✓ Branch 5 taken 38917947 times.
✓ Branch 6 taken 1532 times.
✓ Branch 7 taken 45027 times.
39022651 if(!dying && (force_kill || (hp<=0 && !immortal)))
4484 {
4485 45071 std::vector<int32_t> &ev = FFCore.eventData;
4486 45071 ev.clear();
4487 45071 ev.push_back(10000);
4488 45071 ev.push_back(getUID());
4489
4490 45071 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4491 45071 bool isSaved = !ev[0];
4492 45071 ev.clear();
4493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45071 times.
45071 if(isSaved) return;
4494
4495
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 45014 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 51 times.
45071 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4496 {
4497
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 51 times.
109 for(int32_t i=0; i<items.Count(); i++)
4498 {
4499
4/4
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 51 times.
58 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4500 {
4501
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 10 times.
51 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4502 {
4503
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4504 {
4505 7 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4506 7 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4507 7 }
4508 else
4509 {
4510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4511 {
4512 items.spr(i)->x = x+(txsz-1)*8;
4513 items.spr(i)->y = y-2+(tysz-1)*8;
4514 }
4515 else
4516 {
4517 3 items.spr(i)->x = x;
4518 3 items.spr(i)->y = y - 2;
4519 }
4520 }
4521 10 items.spr(i)->z = z;
4522 10 items.spr(i)->fakez = fakez;
4523 10 }
4524 else
4525 {
4526 41 items.spr(i)->x = x;
4527 41 items.spr(i)->y = y - 2;
4528 }
4529 51 }
4530 58 }
4531 51 }
4532
4533 45071 dying=true;
4534
4535
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 45037 times.
45071 if(fading==fade_flash_die)
4536 34 clk2=19+18*4;
4537 else
4538 {
4539 45037 clk2 = BSZ ? 15 : 19;
4540
4541
2/2
✓ Branch 0 taken 21095 times.
✓ Branch 1 taken 23942 times.
45037 if(fading!=fade_blue_poof)
4542 23942 fading=0;
4543 }
4544
4545
2/2
✓ Branch 0 taken 45014 times.
✓ Branch 1 taken 57 times.
45071 if(itemguy)
4546 {
4547 57 screen_item_set_state(screen_spawned, ScreenItemState::None);
4548 57 item_set=0;
4549 57 }
4550
6/6
✓ Branch 0 taken 44017 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 35248 times.
✓ Branch 3 taken 8769 times.
✓ Branch 4 taken 1489 times.
✓ Branch 5 taken 33759 times.
45071 if (screen_spawned < 128 && count_enemy && !script_spawned)
4551 33759 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4552 45071 }
4553 39022651 }
4554
4555 // --==**==--
4556
4557 // Movement routines that can be used by derived classes as needed
4558
4559 // --==**==--
4560
4561 580449 void enemy::fix_coords(bool bound)
4562 {
4563
1/2
✓ Branch 0 taken 580449 times.
✗ Branch 1 not taken.
580449 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4564
1/2
✓ Branch 0 taken 580449 times.
✗ Branch 1 not taken.
580449 if(moveflags & move_ignore_screenedge) bound = false;
4565
4566
2/2
✓ Branch 0 taken 85032 times.
✓ Branch 1 taken 495417 times.
580449 if(bound)
4567 {
4568 495417 int w = world_w;
4569 495417 int h = world_h;
4570
4571
1/2
✓ Branch 0 taken 495417 times.
✗ Branch 1 not taken.
495417 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4572 {
4573
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 495415 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
495417 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4574
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 495415 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
495417 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4575 495417 }
4576 else
4577 {
4578 x=vbound(x, 0, w-16);
4579 y=vbound(y, 0, h-16);
4580 }
4581 495417 }
4582
4583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580449 times.
580449 if(!OUTOFBOUNDS(id, x, y))
4584 {
4585 580449 do_fix(x, 16, true);
4586
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 579310 times.
580449 if(isSideViewGravity())
4587 1139 do_fix(y,8,true);
4588 579310 else do_fix(y,16,true);
4589 580449 }
4590 580449 }
4591 9316 bool enemy::cannotpenetrate()
4592 {
4593
4/4
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 9097 times.
9316 return (type == eeAQUA || type == eeMANHAN || type == eeGHOMA);
4594 }
4595
4596 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4597 {
4598 bool ok;
4599 562 int32_t dx = 0, dy = 0;
4600 562 int32_t sv = 8;
4601
4602 //Why is this here??? Why is it needed???
4603 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4604
4605
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4606 {
4607 case 8:
4608 case up:
4609
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4610 return false;
4611
4612 69 dy = dy1-s;
4613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4615 69 break;
4616
4617 case 12:
4618 case down:
4619
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4620 return false;
4621
4622 51 dy = dy2+s;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4624 51 break;
4625
4626 case 14:
4627 case left:
4628 47 dx = dx1-s;
4629 47 sv = ((isSideViewGravity())?7:8);
4630
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4632 47 break;
4633
4634 case 10:
4635 case right:
4636 85 dx = dx2+s;
4637 85 sv = ((isSideViewGravity())?7:8);
4638
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4639 85 break;
4640
4641 case 9:
4642 case r_up:
4643 94 dx = dx2+s;
4644 94 dy = dy1-s;
4645
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4647 94 break;
4648
4649 case 11:
4650 case r_down:
4651 78 dx = dx2+s;
4652 78 dx = dy2+s;
4653
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4655 78 break;
4656
4657 case 13:
4658 case l_down:
4659 57 dx = dx1-s;
4660 57 dy = dy2+s;
4661
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4663 57 break;
4664
4665 case 15:
4666 case l_up:
4667 81 dx = dx1-s;
4668 81 dy = dy1-s;
4669
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4671 81 break;
4672
4673 default:
4674 db=99;
4675 return true;
4676 }
4677
4678 562 return ok;
4679 562 }
4680
4681
4682
4683
4684 // returns true if next step is ok, false if there is something there
4685 7645239 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4686 {
4687 7645239 bool ok = false; //initialise the var, son't just declare it
4688 7645239 int32_t dx = 0, dy = 0;
4689 7645239 int32_t sv = 8;
4690 7645239 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4691 //Why is this here??? Why is it needed???
4692 7645239 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7645239 times.
7645239 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7645239 times.
7645239 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4695
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 7645155 times.
7645239 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4696
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 7645155 times.
7645239 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4697 7645239 bool offgrid = OFFGRID_ENEMY;
4698
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7637948 times.
7645239 if(!offgrid)
4699 {
4700 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4701
1/2
✓ Branch 0 taken 7637948 times.
✗ Branch 1 not taken.
7637948 if(usehei<16)usehei=16;
4702
1/2
✓ Branch 0 taken 7637948 times.
✗ Branch 1 not taken.
7637948 if(usewid<16)usewid=16;
4703 7637948 }
4704
9/9
✓ Branch 0 taken 1384486 times.
✓ Branch 1 taken 1156763 times.
✓ Branch 2 taken 1279152 times.
✓ Branch 3 taken 1269730 times.
✓ Branch 4 taken 558497 times.
✓ Branch 5 taken 666174 times.
✓ Branch 6 taken 625432 times.
✓ Branch 7 taken 584251 times.
✓ Branch 8 taken 120754 times.
7645239 switch(ndir) //need to check every 8 pixels between two points
4705 {
4706 case 8:
4707 case up:
4708 {
4709
4/4
✓ Branch 0 taken 165069 times.
✓ Branch 1 taken 1219417 times.
✓ Branch 2 taken 164409 times.
✓ Branch 3 taken 660 times.
1384486 if(enemycanfall(id) && isSideViewGravity())
4710 660 return false;
4711
4712 1383826 dy = dy1-s;
4713
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1383346 times.
1383826 special = (special==spw_clipbottomright)?spw_none:special;
4714 1383826 tries = usewid/(offgrid ? 8 : 16);
4715
4716
2/2
✓ Branch 0 taken 1168843 times.
✓ Branch 1 taken 1384476 times.
2553319 for ( ; tries > 0; --tries )
4717 {
4718
2/2
✓ Branch 0 taken 211888 times.
✓ Branch 1 taken 1172588 times.
1384476 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4719 1384476 try_x += (offgrid ? 8 : 16);
4720
2/2
✓ Branch 0 taken 1169493 times.
✓ Branch 1 taken 214983 times.
1384476 if (!ok) break;
4721 1169493 }
4722
2/2
✓ Branch 0 taken 1168843 times.
✓ Branch 1 taken 214983 times.
1383826 if(!ok) break;
4723
1/2
✓ Branch 0 taken 1168843 times.
✗ Branch 1 not taken.
1168843 if((usewid%16)>0) //Uneven width
4724 {
4725 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4726 }
4727 1168843 break;
4728 }
4729 case 12:
4730 case down:
4731 {
4732
4/4
✓ Branch 0 taken 194058 times.
✓ Branch 1 taken 962705 times.
✓ Branch 2 taken 193332 times.
✓ Branch 3 taken 726 times.
1156763 if(enemycanfall(id) && isSideViewGravity())
4733 726 return false;
4734
4735 1156037 dy = dy2+s;
4736 1156037 tries = usewid/(offgrid ? 8 : 16);
4737
2/2
✓ Branch 0 taken 935910 times.
✓ Branch 1 taken 1156821 times.
2092731 for ( ; tries > 0; --tries )
4738 {
4739
3/4
✓ Branch 0 taken 218891 times.
✓ Branch 1 taken 937930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 937930 times.
1156821 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4740 1156821 try_x += (offgrid ? 8 : 16);
4741
2/2
✓ Branch 0 taken 936694 times.
✓ Branch 1 taken 220127 times.
1156821 if (!ok) break;
4742 936694 }
4743
2/2
✓ Branch 0 taken 935910 times.
✓ Branch 1 taken 220127 times.
1156037 if(!ok) break;
4744
1/2
✓ Branch 0 taken 935910 times.
✗ Branch 1 not taken.
935910 if((usewid%16)>0) //Uneven width
4745 {
4746 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4747 }
4748 935910 break;
4749 }
4750 case 14:
4751 case left:
4752 {
4753 1279152 dx = dx1-s;
4754 1279152 sv = ((isSideViewGravity())?7:0);
4755
4/4
✓ Branch 0 taken 1278529 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1883 times.
✓ Branch 3 taken 1276646 times.
1279152 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4756 1279152 tries = usehei/(offgrid ? 8 : 16);
4757
2/2
✓ Branch 0 taken 1069947 times.
✓ Branch 1 taken 1280069 times.
2350016 for ( ; tries > 0; --tries )
4758 {
4759
2/2
✓ Branch 0 taken 207643 times.
✓ Branch 1 taken 1072426 times.
1280069 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4760 1280069 try_y += (offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 1070864 times.
✓ Branch 1 taken 209205 times.
1280069 if (!ok) break;
4762 1070864 }
4763
2/2
✓ Branch 0 taken 1069947 times.
✓ Branch 1 taken 209205 times.
1279152 if(!ok) break;
4764
1/2
✓ Branch 0 taken 1069947 times.
✗ Branch 1 not taken.
1069947 if((usehei%16)>0) //Uneven height
4765 {
4766 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4767 }
4768 1069947 break;
4769 }
4770 case 10:
4771 case right:
4772 {
4773 1269730 dx = dx2+s;
4774 1269730 sv = ((isSideViewGravity())?7:0);
4775 1269730 tries = usehei/(offgrid ? 8 : 16);
4776
2/2
✓ Branch 0 taken 1073347 times.
✓ Branch 1 taken 1270624 times.
2343971 for ( ; tries > 0; --tries )
4777 {
4778
3/4
✓ Branch 0 taken 194718 times.
✓ Branch 1 taken 1075906 times.
✓ Branch 2 taken 1075906 times.
✗ Branch 3 not taken.
1270624 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4779 1270624 try_y += (offgrid ? 8 : 16);
4780
2/2
✓ Branch 0 taken 1074241 times.
✓ Branch 1 taken 196383 times.
1270624 if (!ok) break;
4781 1074241 }
4782
2/2
✓ Branch 0 taken 1073347 times.
✓ Branch 1 taken 196383 times.
1269730 if(!ok) break;
4783
2/2
✓ Branch 0 taken 1073327 times.
✓ Branch 1 taken 20 times.
1073347 if((usehei%16)>0) //Uneven height
4784 {
4785
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4786 20 }
4787 1073347 break;
4788 }
4789 case 9:
4790 case r_up:
4791 {
4792 558497 dx = dx2+s;
4793 558497 dy = dy1-s;
4794 558497 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4795 558497 sv = ((isSideViewGravity())?7:0);
4796
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 558497 times.
1099152 for ( ; tries_x > 0; --tries_x )
4797 {
4798 558497 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4799 558497 try_y = 0;
4800
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 558497 times.
1099152 for ( ; tries_y > 0; --tries_y )
4801 {
4802
4/4
✓ Branch 0 taken 550183 times.
✓ Branch 1 taken 8314 times.
✓ Branch 2 taken 544702 times.
✓ Branch 3 taken 5481 times.
1103199 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4803
2/2
✓ Branch 0 taken 2841 times.
✓ Branch 1 taken 541861 times.
544702 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4804 558497 try_y += (offgrid ? 8 : 16);
4805
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if (!ok) break;
4806 540655 }
4807
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if (!ok) break;
4808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540655 times.
540655 if((usehei%16)>0) //Uneven height
4809 {
4810 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4811 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4812 }
4813 540655 try_x += (offgrid ? 8 : 16);
4814 540655 }
4815
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if(!ok) break;
4816
1/2
✓ Branch 0 taken 540655 times.
✗ Branch 1 not taken.
540655 if((usewid%16)>0) //Uneven width
4817 {
4818 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4819 try_y = 0;
4820 for ( ; tries_y > 0; --tries_y )
4821 {
4822 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4823 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4824 try_y += (offgrid ? 8 : 16);
4825 if (!ok) break;
4826 }
4827 if (!ok) break;
4828 if((usehei%16)>0) //Uneven height
4829 {
4830 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4831 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4832 }
4833 }
4834 540655 break;
4835 }
4836 case 11:
4837 case r_down:
4838 {
4839 666174 dx = dx2+s;
4840 666174 dx = dy2+s;
4841 666174 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4842 //sv = ((isSideViewGravity())?7:0);
4843
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 666174 times.
1316276 for ( ; tries_x > 0; --tries_x )
4844 {
4845 666174 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4846 666174 try_y = 0;
4847
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 666174 times.
1316276 for ( ; tries_y > 0; --tries_y )
4848 {
4849
4/4
✓ Branch 0 taken 664663 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 651762 times.
✓ Branch 3 taken 12901 times.
1317936 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4850
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 651598 times.
651762 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4851 666174 try_y += (offgrid ? 8 : 16);
4852
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if (!ok) break;
4853 650102 }
4854
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if (!ok) break;
4855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650102 times.
650102 if((usehei%16)>0) //Uneven height
4856 {
4857 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4858 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4859 }
4860 650102 try_x += (offgrid ? 8 : 16);
4861 650102 }
4862
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if(!ok) break;
4863
1/2
✓ Branch 0 taken 650102 times.
✗ Branch 1 not taken.
650102 if((usewid%16)>0) //Uneven width
4864 {
4865 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4866 try_y = 0;
4867 for ( ; tries_y > 0; --tries_y )
4868 {
4869 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4870 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4871 try_y += (offgrid ? 8 : 16);
4872 if (!ok) break;
4873 }
4874 if (!ok) break;
4875 if((usehei%16)>0) //Uneven height
4876 {
4877 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4878 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4879 }
4880 }
4881 650102 break;
4882 }
4883 case 13:
4884 case l_down:
4885 {
4886 625432 dx = dx1-s;
4887 625432 dy = dy2+s;
4888 625432 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4889 //sv = ((isSideViewGravity())?7:0);
4890
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 625432 times.
1233037 for ( ; tries_x > 0; --tries_x )
4891 {
4892 625432 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4893 625432 try_y = 0;
4894
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 625432 times.
1233037 for ( ; tries_y > 0; --tries_y )
4895 {
4896
4/4
✓ Branch 0 taken 613437 times.
✓ Branch 1 taken 11995 times.
✓ Branch 2 taken 609141 times.
✓ Branch 3 taken 4296 times.
1234573 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4897
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 608085 times.
609141 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4898 625432 try_y += (offgrid ? 8 : 16);
4899
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if (!ok) break;
4900 607605 }
4901
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if (!ok) break;
4902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607605 times.
607605 if((usehei%16)>0) //Uneven height
4903 {
4904 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4905 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4906 }
4907 607605 try_x += (offgrid ? 8 : 16);
4908 607605 }
4909
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if(!ok) break;
4910
1/2
✓ Branch 0 taken 607605 times.
✗ Branch 1 not taken.
607605 if((usewid%16)>0) //Uneven width
4911 {
4912 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4913 try_y = 0;
4914 for ( ; tries_y > 0; --tries_y )
4915 {
4916 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4917 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4918 try_y += (offgrid ? 8 : 16);
4919 if (!ok) break;
4920 }
4921 if (!ok) break;
4922 if((usehei%16)>0) //Uneven height
4923 {
4924 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4925 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4926 }
4927 }
4928 607605 break;
4929 }
4930 case 15:
4931 case l_up:
4932 {
4933 584251 dx = dx1-s;
4934 584251 dy = dy1-s;
4935 584251 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4936 584251 sv = ((isSideViewGravity())?7:0);
4937
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 584251 times.
1151922 for ( ; tries_x > 0; --tries_x )
4938 {
4939 584251 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4940 584251 try_y = 0;
4941
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 584251 times.
1151922 for ( ; tries_y > 0; --tries_y )
4942 {
4943
4/4
✓ Branch 0 taken 575555 times.
✓ Branch 1 taken 8696 times.
✓ Branch 2 taken 571553 times.
✓ Branch 3 taken 4002 times.
1155804 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4944
2/2
✓ Branch 0 taken 2807 times.
✓ Branch 1 taken 568746 times.
571553 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4945 584251 try_y += (offgrid ? 8 : 16);
4946
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if (!ok) break;
4947 567671 }
4948
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if (!ok) break;
4949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 567671 times.
567671 if((usehei%16)>0) //Uneven height
4950 {
4951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4953 }
4954 567671 try_x += (offgrid ? 8 : 16);
4955 567671 }
4956
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if(!ok) break;
4957
1/2
✓ Branch 0 taken 567671 times.
✗ Branch 1 not taken.
567671 if((usewid%16)>0) //Uneven width
4958 {
4959 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4960 try_y = 0;
4961 for ( ; tries_y > 0; --tries_y )
4962 {
4963 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4964 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4965 try_y += (offgrid ? 8 : 16);
4966 if (!ok) break;
4967 }
4968 if (!ok) break;
4969 if((usehei%16)>0) //Uneven height
4970 {
4971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4973 }
4974 }
4975 567671 break;
4976 }
4977 default:
4978 120754 db=99;
4979 120754 return true;
4980 }
4981
4982 7523099 return ok;
4983 7645239 }
4984
4985
4986 4811826 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4987 {
4988
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 4811760 times.
4811826 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4989
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 4811760 times.
4811826 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4990
2/2
✓ Branch 0 taken 4811760 times.
✓ Branch 1 taken 66 times.
4811826 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4991
2/2
✓ Branch 0 taken 4811760 times.
✓ Branch 1 taken 66 times.
4811826 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4992 4811826 --usewid;
4993 4811826 --usehei;
4994 4811826 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4995 }
4996
4997 1310489 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4998 {
4999 1310489 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5000
5001
4/4
✓ Branch 0 taken 7284 times.
✓ Branch 1 taken 1303205 times.
✓ Branch 2 taken 5385 times.
✓ Branch 3 taken 1899 times.
1310489 if(special==spw_clipright&&ndir==right)
5002 {
5003 1899 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5004 1899 }
5005
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1310484 times.
1310489 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5006
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1310484 times.
1310489 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5007
1/2
✓ Branch 0 taken 1310489 times.
✗ Branch 1 not taken.
1310489 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5008
1/2
✓ Branch 0 taken 1310489 times.
✗ Branch 1 not taken.
1310489 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5009 1310489 --usewid;
5010 1310489 --usehei;
5011
2/2
✓ Branch 0 taken 760676 times.
✓ Branch 1 taken 549813 times.
1310489 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5012 }
5013
5014 144373 bool enemy::canmove(int32_t ndir, bool kb)
5015 {
5016 144373 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5017 }
5018
5019 // 8-directional
5020 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5021 {
5022 562 int32_t ndir=0;
5023
5024 // can move straight, check if it wants to turn
5025
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5026 {
5027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5028 {
5029 int32_t w = Lwpns.idFirst(wBait);
5030
5031 if(w>=0)
5032 {
5033 int32_t bx = Lwpns.spr(w)->x;
5034 int32_t by = Lwpns.spr(w)->y;
5035
5036 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5037
5038 if(abs(int32_t(y)-by)>14)
5039 {
5040 if(ndir>0) // Already left or right
5041 {
5042 // Making the diagonal directions
5043 ndir += (by<y) ? 2 : 4;
5044 }
5045 else
5046 {
5047 ndir = (by<y) ? up : down;
5048 }
5049 }
5050
5051 if(canmove(ndir,special,false))
5052 {
5053 dir=ndir;
5054 return;
5055 }
5056 }
5057 }
5058
5059 // Homing added.
5060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5061 {
5062 ndir = lined_up(8,true);
5063
5064 if(ndir>=0 && canmove(ndir,special,false))
5065 {
5066 dir=ndir;
5067 }
5068
5069 return;
5070 }
5071
5072 549 int32_t r=zc_oldrand();
5073
5074
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5075 {
5076 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5077 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5078
5079
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5080 525 dir=ndir;
5081
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5082 19 dir=ndir2;
5083
5084
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5085 // due to numerous lost fractional components. -L
5086 {
5087 x.doFloor();
5088 y.doFloor();
5089 }
5090 549 }
5091
5092 549 return;
5093 }
5094
5095 // can't move straight, must turn
5096 13 int32_t i=0;
5097
5098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5099 {
5100 20 ndir=(zc_oldrand()&7)+8;
5101
5102
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5103 13 break;
5104 7 }
5105
5106
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5107 {
5108 for(ndir=8; ndir<16; ndir++)
5109 {
5110 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5111 goto ok;
5112 }
5113
5114 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5115 }
5116
5117 ok:
5118 13 dir=ndir;
5119 13 x.doFloor();
5120 13 y.doFloor();
5121 562 }
5122
5123 600279 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5124 {
5125 600279 int32_t ndir=0;
5126
5127 // can move straight, check if it wants to turn
5128
2/2
✓ Branch 0 taken 566220 times.
✓ Branch 1 taken 34059 times.
600279 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5129 {
5130
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 566013 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
566220 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5131 {
5132 101 int32_t i = Lwpns.idFirst(wBait);
5133
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5134 {
5135 weapon *w = (weapon*)Lwpns.spr(i);
5136 if (get_qr(qr_FIND_CLOSEST_BAIT))
5137 {
5138 int32_t currentrange;
5139 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5140 else currentrange = -1;
5141 int curid = i;
5142 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5143 for(; i<Lwpns.Count(); ++i)
5144 {
5145 weapon *lw = (weapon*)Lwpns.spr(i);
5146 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5147 {
5148 currentrange = distance(x, y, lw->x, lw->y);
5149 curid = i;
5150 }
5151 }
5152 i = curid;
5153 if (currentrange == -1) i = -1;
5154 }
5155 else
5156 {
5157 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5158 }
5159 if(i>=0)
5160 {
5161 int32_t bx = Lwpns.spr(i)->x;
5162 int32_t by = Lwpns.spr(i)->y;
5163
5164 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5165
5166 if(abs(int32_t(y)-by)>14)
5167 {
5168 if(ndir>0) // Already left or right
5169 {
5170 // Making the diagonal directions
5171 ndir += (by<y) ? 2 : 4;
5172 }
5173 else
5174 {
5175 ndir = (by<y) ? up : down;
5176 }
5177 }
5178 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5179 if(canmove(ndir,special,false))
5180 {
5181 dir=ndir;
5182 return;
5183 }
5184 }
5185 }
5186 101 }
5187
5188 // Homing added.
5189
4/4
✓ Branch 0 taken 29843 times.
✓ Branch 1 taken 536377 times.
✓ Branch 2 taken 15574 times.
✓ Branch 3 taken 14269 times.
566220 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5190 {
5191 14269 ndir = lined_up(8,true);
5192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14269 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5193
4/4
✓ Branch 0 taken 9480 times.
✓ Branch 1 taken 4789 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5887 times.
14269 if(ndir>=0 && canmove(ndir,special,false))
5194 {
5195 5887 dir=ndir;
5196 5887 }
5197
5198 14269 return;
5199 }
5200
5201 551951 int32_t r=zc_oldrand();
5202
5203
4/4
✓ Branch 0 taken 347861 times.
✓ Branch 1 taken 204090 times.
✓ Branch 2 taken 183707 times.
✓ Branch 3 taken 164154 times.
551951 if(newrate>0 && !(r%newrate))
5204 {
5205 164154 ndir = ((dir+((r&64)?-1:1))&7)+8;
5206 164154 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5207
5208
2/2
✓ Branch 0 taken 158137 times.
✓ Branch 1 taken 6017 times.
164154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5209 158137 dir=ndir;
5210
2/2
✓ Branch 0 taken 915 times.
✓ Branch 1 taken 5102 times.
6017 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5211 5102 dir=ndir2;
5212
5213
4/4
✓ Branch 0 taken 158137 times.
✓ Branch 1 taken 6017 times.
✓ Branch 2 taken 150795 times.
✓ Branch 3 taken 7342 times.
164154 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5214 // due to numerous lost fractional components. -L
5215 {
5216 7342 x.doFloor();
5217 7342 y.doFloor();
5218 7342 }
5219 164154 }
5220
5221 551951 return;
5222 }
5223
5224 // can't move straight, must turn
5225 34059 int32_t i=0;
5226
5227 // TODO: speed this up!
5228
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 64145 times.
64218 for(; i<32; i++) // Try random dir
5229 {
5230 64145 ndir=(zc_oldrand()&7)+8;
5231
5232
2/2
✓ Branch 0 taken 30159 times.
✓ Branch 1 taken 33986 times.
64145 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5233 33986 break;
5234 30159 }
5235
5236
2/2
✓ Branch 0 taken 33986 times.
✓ Branch 1 taken 73 times.
34115 if(i==32)
5237 {
5238
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 56 times.
541 for(ndir=8; ndir<16; ndir++)
5239 {
5240
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 17 times.
485 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5241 17 goto ok;
5242 468 }
5243
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5245 56 }
5246
5247 ok:
5248 34059 dir=ndir;
5249 34059 x.doFloor();
5250 34059 y.doFloor();
5251 600279 }
5252
5253 593804 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5254 {
5255 593804 newdir_8(newrate,newhoming,special,0,-8,15,15);
5256 593804 }
5257
5258 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5259 {
5260 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5261 562 }
5262
5263 // makes the enemy slide backwards when hit
5264 // sclk: first byte is clk, second byte is dir
5265 // makes the enemy slide backwards when hit
5266 // sclk: first byte is clk, second byte is dir
5267 16426906 int32_t enemy::slide()
5268 {
5269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16426906 times.
16426906 if(script_knockback_clk!=0) //scripted knockback
5270 {
5271 sclk = 0;
5272 return 1; //scripted knockback ran
5273 }
5274
5/6
✓ Branch 0 taken 112516 times.
✓ Branch 1 taken 16314390 times.
✓ Branch 2 taken 8816 times.
✓ Branch 3 taken 103700 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8816 times.
16426906 if(sclk==0 || (hp<=0 && !immortal))
5275 16323206 return 0;
5276
5277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103700 times.
103700 if(knockbackflags & FLAG_NOSLIDE)
5278 {
5279 sclk = 0;
5280 if(!OFFGRID_ENEMY)
5281 {
5282 //Fix to grid
5283 do_fix(x, 16, true);
5284 do_fix(y, 16, true);
5285 }
5286 return 0;
5287 }
5288
8/10
✓ Branch 0 taken 10496 times.
✓ Branch 1 taken 93204 times.
✓ Branch 2 taken 1240 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1240 times.
✓ Branch 6 taken 7047 times.
✓ Branch 7 taken 2209 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1240 times.
103700 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5289 {
5290 2209 sclk=0;
5291 2209 return 0;
5292 }
5293
5294 101491 --sclk;
5295
5296
5/5
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 11704 times.
✓ Branch 2 taken 13482 times.
✓ Branch 3 taken 35799 times.
✓ Branch 4 taken 38291 times.
101491 switch(sclk>>8)
5297 {
5298 case up:
5299 {
5300
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 10614 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 11697 times.
11704 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5301 {
5302 7 sclk=0;
5303 7 return 0;
5304 }
5305
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 10607 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
11697 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5306
5307 11522 break;
5308 }
5309 case down:
5310 {
5311
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13480 times.
13482 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5312 {
5313 2 sclk=0;
5314 2 return 0;
5315 }
5316
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 12411 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
13480 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5317
5318 13334 break;
5319 }
5320 case left:
5321 {
5322
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 33445 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 35786 times.
35799 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5323 {
5324 13 sclk=0;
5325 13 return 0;
5326 }
5327
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 33432 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
35786 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5328
5329 35548 break;
5330 }
5331 case right:
5332 {
5333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38291 times.
38291 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5334 {
5335 sclk=0;
5336 return 0;
5337 }
5338
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 35003 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
38291 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5339 38021 break;
5340 }
5341 }
5342
5343 100640 int32_t move = knockbackSpeed;
5344
2/2
✓ Branch 0 taken 95201 times.
✓ Branch 1 taken 100640 times.
195841 while(move>0)
5345 {
5346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100640 times.
100640 int32_t thismove = zc_min(8, move);
5347 100640 move -= thismove;
5348 100640 hitdir = (sclk>>8);
5349
5/5
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 11522 times.
✓ Branch 2 taken 13334 times.
✓ Branch 3 taken 35548 times.
✓ Branch 4 taken 38021 times.
100640 switch(sclk>>8)
5350 {
5351 case up:
5352 11522 y-=thismove;
5353 11522 break;
5354
5355 case down:
5356 13334 y+=thismove;
5357 13334 break;
5358
5359 case left:
5360 35548 x-=thismove;
5361 35548 break;
5362
5363 case right:
5364 38021 x+=thismove;
5365 38021 break;
5366 }
5367
2/2
✓ Branch 0 taken 95201 times.
✓ Branch 1 taken 5439 times.
100640 if(!canmove(sclk>>8,(zfix)0,0,true))
5368 {
5369
3/3
✓ Branch 0 taken 2227 times.
✓ Branch 1 taken 3208 times.
✓ Branch 2 taken 4 times.
5439 switch(sclk>>8)
5370 {
5371 case up:
5372 case down:
5373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2227 times.
2227 if(y < 0)
5374 y = 0;
5375
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 1849 times.
2227 else if((int32_t(y)&15) > 7)
5376 378 y = TRUNCATE_TILE(int32_t(y)) + 16;
5377 else
5378 1849 y = TRUNCATE_TILE(int32_t(y));
5379
5380 2227 break;
5381
5382 case left:
5383 case right:
5384
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3167 times.
3208 if(x < 0)
5385 41 x = 0;
5386
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 2258 times.
3167 else if((int32_t(x)&15) > 7)
5387 909 x = TRUNCATE_TILE(int32_t(x)) + 16;
5388 else
5389 2258 x = TRUNCATE_TILE(int32_t(x));
5390
5391 3208 break;
5392 }
5393
5394 5439 sclk=0;
5395 5439 clk3=0;
5396 5439 break;
5397 }
5398 }
5399
5400
2/2
✓ Branch 0 taken 92423 times.
✓ Branch 1 taken 8217 times.
100640 if((sclk&255)==0)
5401 {
5402 //hitdir = -1;
5403 8217 sclk=0;
5404 8217 }
5405 100640 return 2;
5406 16426906 }
5407
5408 bool enemy::can_slide()
5409 {
5410 if(sclk==0 || (hp<=0 && !immortal))
5411 return false;
5412
5413 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5414 {
5415 return false;
5416 }
5417
5418 return true;
5419 }
5420
5421 bool enemy::fslide()
5422 {
5423 if(sclk==0 || (hp<=0 && !immortal))
5424 return false;
5425
5426 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5427 {
5428 sclk=0;
5429 return false;
5430 }
5431
5432 --sclk;
5433
5434 switch(sclk>>8)
5435 {
5436 case up:
5437 if(y<=16)
5438 {
5439 sclk=0;
5440 return false;
5441 }
5442
5443 break;
5444
5445 case down:
5446 if(y>=world_h-16)
5447 {
5448 sclk=0;
5449 return false;
5450 }
5451
5452 break;
5453
5454 case left:
5455 if(x<=16)
5456 {
5457 sclk=0;
5458 return false;
5459 }
5460
5461 break;
5462
5463 case right:
5464 if(x>=world_w-16)
5465 {
5466 sclk=0;
5467 return false;
5468 }
5469
5470 break;
5471 }
5472 hitdir = (sclk>>8);
5473 switch(sclk>>8)
5474 {
5475 case up:
5476 y-=4;
5477 break;
5478
5479 case down:
5480 y+=4;
5481 break;
5482
5483 case left:
5484 x-=4;
5485 break;
5486
5487 case right:
5488 x+=4;
5489 break;
5490 }
5491
5492 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5493 {
5494 switch(sclk>>8)
5495 {
5496 case up:
5497 case down:
5498 if((int32_t(y)&15) > 7)
5499 y = TRUNCATE_TILE(int32_t(y)) + 16;
5500 else
5501 y = TRUNCATE_TILE(int32_t(y));
5502
5503 break;
5504
5505 case left:
5506 case right:
5507 if((int32_t(x)&15) > 7)
5508 x = TRUNCATE_TILE(int32_t(x)) + 16;
5509 else
5510 x = TRUNCATE_TILE(int32_t(x));
5511
5512 break;
5513 }
5514
5515 sclk=0;
5516 clk3=0;
5517 }
5518
5519 if((sclk&255)==0)
5520 sclk=0;
5521
5522 return true;
5523 }
5524
5525 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5526 {
5527 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5528 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5529 bool ret = sprite::knockback(time, dir, speed);
5530 if(ret) sclk = 0; //kill engine knockback if interrupted
5531 //! Perhaps also set hitdir here, if needed for timing? -Z
5532 return ret;
5533 }
5534
5535 39022607 bool enemy::runKnockback()
5536 {
5537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39022607 times.
39022607 if((script_knockback_clk&0xFF)==0)
5538 {
5539 39022607 script_knockback_clk = 0;
5540 39022607 return false;
5541 }
5542 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5543 {
5544 return false;
5545 }
5546 int32_t move = script_knockback_speed;
5547 int32_t kb_dir = script_knockback_clk>>8;
5548 --script_knockback_clk;
5549
5550 while(move>0)
5551 {
5552 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5553 move -= thismove;
5554 hitdir = kb_dir;
5555 switch(kb_dir)
5556 {
5557 case r_up:
5558 case l_up:
5559 case up:
5560 y-=thismove;
5561 break;
5562
5563 case r_down:
5564 case l_down:
5565 case down:
5566 y+=thismove;
5567 break;
5568 }
5569 switch(kb_dir)
5570 {
5571 case l_up:
5572 case l_down:
5573 case left:
5574 x-=thismove;
5575 break;
5576
5577 case r_up:
5578 case r_down:
5579 case right:
5580 x+=thismove;
5581 break;
5582 }
5583 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5584 {
5585 if(!canmove(kb_dir,(zfix)0,0,true))
5586 {
5587 script_knockback_clk=0;
5588 clk3=0;
5589 //Fix to grid
5590 switch(kb_dir)
5591 {
5592 case up:
5593 case down:
5594 break;
5595 default:
5596 if(x < 0)
5597 x = 0;
5598 else if((int32_t(x)&15) > 7)
5599 x = TRUNCATE_TILE(int32_t(x)) + 16;
5600 else
5601 x = TRUNCATE_TILE(int32_t(x));
5602 break;
5603 }
5604 switch(kb_dir)
5605 {
5606 case left:
5607 case right:
5608 break;
5609 default:
5610 if(y < 0)
5611 y = 0;
5612 else if((int32_t(y)&15) > 7)
5613 y = TRUNCATE_TILE(int32_t(y)) + 16;
5614 else
5615 y = TRUNCATE_TILE(int32_t(y));
5616 break;
5617 }
5618 break;
5619 }
5620 }
5621 else
5622 {
5623 if(!scr_canplace(x,y,0,true))
5624 {
5625 script_knockback_clk=0;
5626 clk3=0;
5627 //Fix to grid
5628 if (OFFGRID_ENEMY)
5629 {
5630 switch(kb_dir)
5631 {
5632 case up:
5633 case down:
5634 break;
5635 default:
5636 if(x < 0)
5637 x = 0;
5638 else if((int32_t(x)&7) > 3)
5639 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5640 else
5641 x = TRUNCATE_HALF_TILE(int32_t(x));
5642 break;
5643 }
5644 switch(kb_dir)
5645 {
5646 case left:
5647 case right:
5648 break;
5649 default:
5650 if(y < 0)
5651 y = 0;
5652 else if((int32_t(y)&7) > 3)
5653 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5654 else
5655 y = TRUNCATE_HALF_TILE(int32_t(y));
5656 break;
5657 }
5658 }
5659 else
5660 {
5661 switch(kb_dir)
5662 {
5663 case up:
5664 case down:
5665 break;
5666 default:
5667 if(x < 0)
5668 x = 0;
5669 else if((int32_t(x)&15) > 7)
5670 x = TRUNCATE_TILE(int32_t(x)) + 16;
5671 else
5672 x = TRUNCATE_TILE(int32_t(x));
5673 break;
5674 }
5675 switch(kb_dir)
5676 {
5677 case left:
5678 case right:
5679 break;
5680 default:
5681 if(y < 0)
5682 y = 0;
5683 else if((int32_t(y)&15) > 7)
5684 y = TRUNCATE_TILE(int32_t(y)) + 16;
5685 else
5686 y = TRUNCATE_TILE(int32_t(y));
5687 break;
5688 }
5689 }
5690 break;
5691 }
5692
5693 }
5694 }
5695 return true;
5696 39022607 }
5697 // changes enemy's direction, checking restrictions
5698 // rate: 0 = no random changes, 16 = always random change
5699 // homing: 0 = none, 256 = always
5700 // grumble 0 = none, 4 = strongest appetite
5701 543806 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5702 {
5703 543806 int32_t ndir=-1;
5704
5705
4/4
✓ Branch 0 taken 115116 times.
✓ Branch 1 taken 428690 times.
✓ Branch 2 taken 40416 times.
✓ Branch 3 taken 74700 times.
543806 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5706 {
5707 74700 int32_t i = Lwpns.idFirst(wBait);
5708
1/2
✓ Branch 0 taken 74700 times.
✗ Branch 1 not taken.
74700 if(i >= 0) //idfirst returns -1 if it can't find any
5709 {
5710 weapon *w = (weapon*)Lwpns.spr(i);
5711 if (get_qr(qr_FIND_CLOSEST_BAIT))
5712 {
5713 int32_t currentrange;
5714 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5715 else currentrange = -1;
5716 int curid = i;
5717 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5718 for(; i<Lwpns.Count(); ++i)
5719 {
5720 weapon *lw = (weapon*)Lwpns.spr(i);
5721 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5722 {
5723 currentrange = distance(x, y, lw->x, lw->y);
5724 curid = i;
5725 }
5726 }
5727 i = curid;
5728 if (currentrange == -1) i = -1;
5729 }
5730 else
5731 {
5732 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5733 }
5734 if (i >= 0)
5735 {
5736 int32_t bx = Lwpns.spr(i)->x;
5737 int32_t by = Lwpns.spr(i)->y;
5738
5739 if(abs(int32_t(y)-by)>14)
5740 {
5741 ndir = (by<y) ? up : down;
5742 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5743 if(canmove(ndir,special,false))
5744 {
5745 dir=ndir;
5746 return;
5747 }
5748 }
5749
5750 ndir = (bx<x) ? left : right;
5751 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5752 if(canmove(ndir,special,false))
5753 {
5754 dir=ndir;
5755 return;
5756 }
5757 }
5758 }
5759 74700 }
5760
5761
2/2
✓ Branch 0 taken 366111 times.
✓ Branch 1 taken 177695 times.
543806 if((zc_oldrand()&255)<abs(newhoming))
5762 {
5763 177695 ndir = lined_up(8,false);
5764
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177695 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5765
4/4
✓ Branch 0 taken 47587 times.
✓ Branch 1 taken 130108 times.
✓ Branch 2 taken 5915 times.
✓ Branch 3 taken 41672 times.
177695 if(ndir>=0 && canmove(ndir,special,false))
5766 {
5767 41672 dir=ndir;
5768 41672 return;
5769 }
5770 136023 }
5771
5772 502134 int32_t i=0;
5773
5774
2/2
✓ Branch 0 taken 3951 times.
✓ Branch 1 taken 1243488 times.
1247439 for(; i<32; i++)
5775 {
5776 1243488 int32_t r=zc_oldrand();
5777
5778
2/2
✓ Branch 0 taken 356725 times.
✓ Branch 1 taken 886763 times.
1243488 if((r&15)<newrate)
5779 356725 ndir=(r>>4)&3;
5780 else
5781 886763 ndir=dir;
5782
5783
2/2
✓ Branch 0 taken 745305 times.
✓ Branch 1 taken 498183 times.
1243488 if(canmove(ndir,special,false))
5784 498183 break;
5785 745305 }
5786
5787
2/2
✓ Branch 0 taken 498183 times.
✓ Branch 1 taken 3951 times.
502896 if(i==32)
5788 {
5789
2/2
✓ Branch 0 taken 9934 times.
✓ Branch 1 taken 762 times.
10696 for(ndir=0; ndir<4; ndir++)
5790 {
5791
2/2
✓ Branch 0 taken 6745 times.
✓ Branch 1 taken 3189 times.
9934 if(canmove(ndir,special,false))
5792 3189 goto ok;
5793 6745 }
5794
5795
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 702 times.
762 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5796 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5797 762 }
5798
5799 ok:
5800 502134 dir = ndir;
5801 543806 }
5802
5803 2822 void enemy::newdir()
5804 {
5805 2822 newdir(4,0,spw_none);
5806 2822 }
5807
5808 zfix enemy::distance_left()
5809 {
5810 int32_t a2=x.getInt();
5811 int32_t b2=y.getInt();
5812
5813 switch(dir)
5814 {
5815 case up:
5816 return (zfix)(b2&0xF);
5817
5818 case down:
5819 return (zfix)(16-(b2&0xF));
5820
5821 case left:
5822 return (zfix)(a2&0xF);
5823
5824 case right:
5825 return (zfix)(16-(a2&0xF));
5826 }
5827
5828 return (zfix)0;
5829 }
5830
5831 // keeps walking around
5832 397833 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5833 {
5834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397833 times.
397833 if(slide())
5835 return;
5836
5837
8/12
✓ Branch 0 taken 393987 times.
✓ Branch 1 taken 3846 times.
✓ Branch 2 taken 393987 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 389427 times.
✓ Branch 5 taken 4560 times.
✓ Branch 6 taken 389427 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 389427 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 389427 times.
397833 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5838 8406 return;
5839
5840
2/2
✓ Branch 0 taken 26349 times.
✓ Branch 1 taken 363078 times.
389427 if(clk3<=0)
5841 {
5842 26349 fix_coords(true);
5843 26349 newdir(newrate,newhoming,special);
5844
5845
1/2
✓ Branch 0 taken 26349 times.
✗ Branch 1 not taken.
26349 if(step==0)
5846 clk3=0;
5847 else
5848 26349 clk3=int32_t(16.0/step);
5849 26349 }
5850
2/2
✓ Branch 0 taken 363029 times.
✓ Branch 1 taken 49 times.
363078 else if(scored)
5851 {
5852 49 dir^=1;
5853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5854 else clk3=32767;
5855 49 }
5856
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 389427 times.
389427 if (step != 0) --clk3;
5858 389427 move(step);
5859 397833 }
5860
5861 void enemy::constant_walk()
5862 {
5863 constant_walk(4,0,spw_none);
5864 }
5865
5866 43048 int32_t enemy::pos(int32_t newx,int32_t newy)
5867 {
5868 43048 return (newy<<8)+newx;
5869 }
5870
5871 // for variable step rates
5872 570827 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5873 {
5874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570827 times.
570827 if(slide())
5875 return;
5876
5877
10/14
✓ Branch 0 taken 570827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 570827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 562132 times.
✓ Branch 5 taken 8695 times.
✓ Branch 6 taken 552858 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 496046 times.
✓ Branch 9 taken 56812 times.
✓ Branch 10 taken 496046 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 496046 times.
✗ Branch 13 not taken.
570827 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5878 74781 return;
5879
5880 496046 zfix dx = (zfix)0;
5881 496046 zfix dy = (zfix)0;
5882
5883
5/9
✓ Branch 0 taken 118413 times.
✓ Branch 1 taken 122486 times.
✓ Branch 2 taken 123941 times.
✓ Branch 3 taken 128998 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2208 times.
496046 switch(dir)
5884 {
5885 case 8:
5886 case up:
5887 118413 dy-=step;
5888 118413 break;
5889
5890 case 12:
5891 case down:
5892 122486 dy+=step;
5893 122486 break;
5894
5895 case 14:
5896 case left:
5897 123941 dx-=step;
5898 123941 break;
5899
5900 case 10:
5901 case right:
5902 128998 dx+=step;
5903 128998 break;
5904
5905 case 15:
5906 case l_up:
5907 dx-=step;
5908 dy-=step;
5909 break;
5910
5911 case 9:
5912 case r_up:
5913 dx+=step;
5914 dy-=step;
5915 break;
5916
5917 case 13:
5918 case l_down:
5919 dx-=step;
5920 dy+=step;
5921 break;
5922
5923 case 11:
5924 case r_down:
5925 dx+=step;
5926 dy+=step;
5927 break;
5928 }
5929
5930
8/8
✓ Branch 0 taken 255737 times.
✓ Branch 1 taken 240309 times.
✓ Branch 2 taken 27253 times.
✓ Branch 3 taken 228484 times.
✓ Branch 4 taken 13974 times.
✓ Branch 5 taken 13279 times.
✓ Branch 6 taken 480251 times.
✓ Branch 7 taken 15795 times.
496046 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5931 482072 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5932 {
5933 15795 fix_coords();
5934 15795 newdir(newrate,newhoming,special);
5935 15795 clk3=pos(x,y);
5936 15795 }
5937
5938 496046 move(step);
5939 570827 }
5940
5941 // pauses for a while after it makes a complete move (to a new square)
5942 12789274 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5943 {
5944
4/4
✓ Branch 0 taken 85091 times.
✓ Branch 1 taken 12704183 times.
✓ Branch 2 taken 71149 times.
✓ Branch 3 taken 13942 times.
12789274 if(sclk && clk2)
5945 {
5946 13942 clk3=0;
5947 13942 }
5948
5949
11/14
✓ Branch 0 taken 12711505 times.
✓ Branch 1 taken 77769 times.
✓ Branch 2 taken 12711505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12711505 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12242919 times.
✓ Branch 7 taken 468586 times.
✓ Branch 8 taken 12105170 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 12094281 times.
✓ Branch 11 taken 10889 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 12094281 times.
12789274 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5950 {
5951 694993 return;
5952 }
5953
5954
2/2
✓ Branch 0 taken 2228493 times.
✓ Branch 1 taken 9865788 times.
12094281 if(clk2>0)
5955 {
5956 2228493 --clk2;
5957 2228493 return;
5958 }
5959
5960
2/2
✓ Branch 0 taken 428146 times.
✓ Branch 1 taken 9437642 times.
9865788 if(clk3<=0)
5961 {
5962 428146 fix_coords(true);
5963 428146 newdir(newrate,newhoming,special);
5964 428146 clk3=int32_t(16.0/step);
5965
2/2
✓ Branch 0 taken 427949 times.
✓ Branch 1 taken 197 times.
428146 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428146 times.
428146 if(clk2<0)
5967 {
5968 clk2=0;
5969 }
5970
2/2
✓ Branch 0 taken 57028 times.
✓ Branch 1 taken 371118 times.
428146 else if((zc_oldrand()&15)<newhrate)
5971 {
5972 57028 clk2=haltcnt;
5973 57028 return;
5974 }
5975 371118 }
5976
2/2
✓ Branch 0 taken 9434349 times.
✓ Branch 1 taken 3293 times.
9437642 else if(scored)
5977 {
5978 3293 dir^=1;
5979
5980
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3288 times.
3293 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5981 5 else clk3=32767;
5982 3293 }
5983
5984
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9731821 times.
9808760 if (step != 0) --clk3;
5985 9808760 move(step);
5986 12789274 }
5987
5988 // 8-directional movement, aligns to 8 pixels
5989 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5990 {
5991 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5992 return;
5993
5994 if(clk3<=0)
5995 {
5996 newdir_8(newrate,newhoming,special);
5997 clk3=int32_t(8.0/step);
5998 if (step == 0) clk3 = 32767;
5999 }
6000
6001 if (step != 0) --clk3;
6002 move(step);
6003 }
6004 // 8-directional movement, aligns to 8 pixels
6005 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6006 {
6007
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6008 return;
6009
6010
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6011 {
6012 16235 newdir_8(newrate,newhoming,special);
6013 16235 clk3=int32_t(8.0/step);
6014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6015 16235 }
6016
6017
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6018 242393 move(step);
6019 242393 }
6020
6021 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6022 {
6023 if(clk<0 || dying || stunclk || watch || frozenclock)
6024 return;
6025
6026 if(!canmove(dir,step,special,false))
6027 clk3=0;
6028
6029 if(clk2>0)
6030 {
6031 --clk2;
6032 return;
6033 }
6034
6035 if(clk3<=0)
6036 {
6037 newdir_8(newrate,newhoming,special);
6038 clk3=newclk;
6039
6040 if(clk2<0)
6041 {
6042 clk2=0;
6043 }
6044 else if((zc_oldrand()&15)<newhrate)
6045 {
6046 newdir_8(newrate,newhoming,special);
6047 clk2=haltcnt;
6048 return;
6049 }
6050 }
6051
6052 --clk3;
6053 move(step);
6054 }
6055
6056 // 8-directional movement, no alignment
6057 4872408 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6058 {
6059
9/12
✓ Branch 0 taken 4661743 times.
✓ Branch 1 taken 210665 times.
✓ Branch 2 taken 4661743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4635122 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4624075 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4624075 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4624075 times.
4872408 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6060 248333 return;
6061
6062
2/2
✓ Branch 0 taken 4592191 times.
✓ Branch 1 taken 31884 times.
4624075 if(!canmove(dir,step,special,false))
6063 31884 clk3=0;
6064
6065
2/2
✓ Branch 0 taken 4046506 times.
✓ Branch 1 taken 577569 times.
4624075 if(clk3<=0)
6066 {
6067 577569 newdir_8(newrate,newhoming,special);
6068 577569 clk3=newclk;
6069 577569 }
6070
6071 4624075 --clk3;
6072 4624075 move(step);
6073 4872408 }
6074
6075 // same as above but with variable enemy size
6076 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6077 {
6078
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6079 1247 return;
6080
6081
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6082 1334 clk3=0;
6083
6084
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6085 {
6086 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6087 6475 clk3=newclk;
6088 6475 }
6089
6090 93316 --clk3;
6091 93316 move(step);
6092 94563 }
6093
6094 // the variable speed floater movement
6095 // ms is max speed
6096 // ss is step speed
6097 // s is step count
6098 // p is pause count
6099 // g is graduality :)
6100 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6101 4170490 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6102 {
6103 4170490 ++clk2;
6104 4170490 bool over_pit = overpit();
6105
6106
4/4
✓ Branch 0 taken 1127398 times.
✓ Branch 1 taken 3043092 times.
✓ Branch 2 taken 1127057 times.
✓ Branch 3 taken 341 times.
4170490 if(dmisc1 && over_pit) p = 0;
6107
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 58167 times.
✓ Branch 2 taken 1664287 times.
✓ Branch 3 taken 2309513 times.
✓ Branch 4 taken 138523 times.
4170490 switch(movestatus)
6108 {
6109 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6110 //! if the conditions prevent it, we jump back to case 2.
6111 case 0: // paused
6112
2/2
✓ Branch 0 taken 56695 times.
✓ Branch 1 taken 1472 times.
58167 if(clk2>=p)
6113 {
6114 1472 movestatus=1;
6115 1472 clk2=0;
6116 1472 }
6117
6118 58167 break;
6119
6120 case 1: // speeding up
6121
1/2
✓ Branch 0 taken 1664287 times.
✗ Branch 1 not taken.
1664287 if (s >= 0)
6122 {
6123
2/2
✓ Branch 0 taken 1652642 times.
✓ Branch 1 taken 11645 times.
1664287 if(clk2<g*s)
6124 {
6125
2/2
✓ Branch 0 taken 1546014 times.
✓ Branch 1 taken 106628 times.
1652642 if(!((clk2-1)%g))
6126 106628 step+=ss;
6127 1652642 }
6128 else
6129 {
6130 11645 movestatus=2;
6131 11645 clk2=0;
6132 }
6133 1664287 }
6134 else
6135 {
6136 if(step < ms)
6137 {
6138 if(!((clk2-1)%g))
6139 {
6140 step+=ss;
6141 if (step >= ms) step = ms;
6142 }
6143 }
6144 else
6145 {
6146 step = ms;
6147 movestatus=2;
6148 clk2=0;
6149 }
6150 }
6151
6152 1664287 break;
6153
6154 case 2: // normal
6155 2309513 step=ms;
6156
6157
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2309513 times.
✓ Branch 2 taken 495344 times.
✓ Branch 3 taken 1814169 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1814169 times.
✓ Branch 6 taken 1811852 times.
✓ Branch 7 taken 2317 times.
2309513 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6158 {
6159
1/2
✓ Branch 0 taken 2317 times.
✗ Branch 1 not taken.
2317 if (s >= 0) step=ss*s;
6160 else step=ms;
6161 2317 movestatus=3;
6162 2317 clk2=0;
6163 2317 }
6164
6165 2309513 break;
6166
6167 case 3: // slowing down
6168
1/2
✓ Branch 0 taken 138523 times.
✗ Branch 1 not taken.
138523 if (s >= 0)
6169 {
6170
2/2
✓ Branch 0 taken 136812 times.
✓ Branch 1 taken 1711 times.
138523 if(clk2<=g*s)
6171 {
6172 { //don't slow down over pits
6173
6174
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 136373 times.
136812 if(over_pit)
6175 {
6176
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(dmisc1)
6177 {
6178 step=ms;
6179 }
6180 439 }
6181 else //can slow down
6182 {
6183
4/4
✓ Branch 0 taken 8399 times.
✓ Branch 1 taken 127974 times.
✓ Branch 2 taken 8031 times.
✓ Branch 3 taken 368 times.
136373 if(!(clk2%g) && !dmisc1)
6184 8031 step-=ss;
6185 }
6186 }
6187
6188
6189 136812 }
6190 else
6191 {
6192 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6193 //this doesn't help keese, as they have a z of 0.
6194 //they always nee to run this check.
6195 {
6196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1711 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1711 if(over_pit &&!dmisc1)
6197 {
6198 --clk2; //if over a pit, don't land, and revert clock change
6199 }
6200 else //can land safely
6201 {
6202 1711 movestatus=0;
6203
3/4
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1128 times.
1711 if(dmisc1&&!over_pit)
6204 1128 step=0;
6205 1711 clk2=0;
6206 }
6207 }
6208
6209 }
6210 138523 }
6211 else
6212 {
6213 if(step > 0)
6214 {
6215 if(over_pit)
6216 {
6217 if(dmisc1)
6218 {
6219 step=ms;
6220 }
6221 }
6222 else //can slow down
6223 {
6224 if(!(clk2%g))
6225 step-=ss;
6226 }
6227 }
6228 else
6229 {
6230 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6231 //this doesn't help keese, as they have a z of 0.
6232 //they always nee to run this check.
6233 if(over_pit)
6234 {
6235 step+=ss; //if over a pit, don't land, and revert clock change
6236 }
6237 else //can land safely
6238 {
6239 movestatus=0;
6240 step=0;
6241 clk2=0;
6242 }
6243 }
6244 }
6245
6246 138523 break;
6247 }
6248
6249
2/2
✓ Branch 0 taken 2318841 times.
✓ Branch 1 taken 1851649 times.
4170490 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6250 4170490 }
6251
6252 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6253 {
6254 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6255 }
6256
6257 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6258 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6259 949410 int32_t enemy::lined_up(int32_t range, bool dir8)
6260 {
6261 949410 int32_t lx = Hero.getX();
6262 949410 int32_t ly = Hero.getY();
6263
6264
2/2
✓ Branch 0 taken 40417 times.
✓ Branch 1 taken 908993 times.
949410 if(abs(lx-int32_t(x))<=range)
6265 {
6266
2/2
✓ Branch 0 taken 16864 times.
✓ Branch 1 taken 23553 times.
40417 if(ly<y)
6267 {
6268 16864 return up;
6269 }
6270
6271 23553 return down;
6272 }
6273
6274
2/2
✓ Branch 0 taken 58505 times.
✓ Branch 1 taken 850488 times.
908993 if(abs(ly-int32_t(y))<=range)
6275 {
6276
2/2
✓ Branch 0 taken 31464 times.
✓ Branch 1 taken 27041 times.
58505 if(lx<x)
6277 {
6278 31464 return left;
6279 }
6280
6281 27041 return right;
6282 }
6283
6284
2/2
✓ Branch 0 taken 169486 times.
✓ Branch 1 taken 681002 times.
850488 if(dir8)
6285 {
6286
2/2
✓ Branch 0 taken 256739 times.
✓ Branch 1 taken 424263 times.
681002 if(abs(lx-x)-abs(ly-y)<=range)
6287 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6288 {
6289
2/2
✓ Branch 0 taken 106856 times.
✓ Branch 1 taken 149883 times.
256739 if(ly<y)
6290 {
6291
2/2
✓ Branch 0 taken 57358 times.
✓ Branch 1 taken 49498 times.
106856 if(lx<x)
6292 {
6293 57358 return l_up;
6294 }
6295 else
6296 {
6297 49498 return r_up;
6298 }
6299 }
6300 else
6301 {
6302
2/2
✓ Branch 0 taken 77422 times.
✓ Branch 1 taken 72461 times.
149883 if(lx<x)
6303 {
6304 72461 return l_down;
6305 }
6306 else
6307 {
6308 77422 return r_down;
6309 }
6310 }
6311 }
6312 424263 }
6313
6314 593749 return -1;
6315 949410 }
6316
6317 // returns true if Hero is within 'range' pixels of the enemy
6318 27887 bool enemy::HeroInRange(int32_t range)
6319 {
6320 27887 int32_t lx = Hero.getX();
6321 27887 int32_t ly = Hero.getY();
6322
2/2
✓ Branch 0 taken 22778 times.
✓ Branch 1 taken 5109 times.
27887 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6323 }
6324
6325 // place the enemy in line with Hero (red wizzrobes)
6326 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6327 {
6328
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6329
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6330 4899 int32_t pos2=zc_oldrand()%23;
6331 4899 int32_t tried=0;
6332 4899 bool last_resort,placed=false;
6333
6334
6335 4899 do
6336 {
6337
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6338 {
6339 4460 x=(pos2<<4)+16;
6340 4460 y=ly;
6341 4460 }
6342 else
6343 {
6344 3127 x=lx;
6345 3127 y=((pos2-14)<<4)+16;
6346 }
6347
6348 // Don't commit to a last resort if position is out of bounds.
6349
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6350
6351
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1425 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6352 {
6353 // Red Wizzrobes should be able to appear on water, but not other
6354 // solid combos; however, they could appear on solid combos in 2.10,
6355 // and some quests depend on that.
6356
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6357 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6358 4899 placed=true;
6359 8542 }
6360
6361
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4675 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7363 if(!placed && tried>=22 && last_resort)
6362 {
6363 placed=true;
6364 }
6365
6366 7363 ++tried;
6367 7363 pos2=(pos2+3)%23;
6368
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4675 times.
7363 }
6369 7363 while(!placed);
6370
6371
2/2
✓ Branch 0 taken 2867 times.
✓ Branch 1 taken 1808 times.
4675 if(y==ly)
6372 2867 dir=(x<lx)?right:left;
6373 else
6374 1808 dir=(y<ly)?down:up;
6375
6376 4675 clk2=tried;
6377 4675 }
6378
6379 21479608 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6380 {
6381 21479608 int32_t t = o_tile;
6382 21479608 int32_t b = o_tile;
6383
6384 // Darknuts, but also Wizzrobes and Wallmasters
6385
3/4
✓ Branch 0 taken 8940679 times.
✓ Branch 1 taken 11462151 times.
✓ Branch 2 taken 1076778 times.
✗ Branch 3 not taken.
21479608 switch(type)
6386 {
6387 case eeWALK:
6388
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10956744 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
11462151 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6389 {
6390 367468 tile=s_tile;
6391 367468 t=s_tile;
6392 367468 b=s_tile;
6393 367468 }
6394
6395 11462151 break;
6396
6397 case eeTRAP:
6398
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 883212 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1076778 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6399 {
6400 193566 tile=s_tile;
6401 193566 t=s_tile;
6402 193566 b=s_tile;
6403 193566 }
6404
6405 1076778 break;
6406
6407 case eeSPINTILE:
6408 if(misc>=96 && do_animation)
6409 {
6410 tile=o_tile+frames*ndir;
6411 t=tile;
6412 }
6413
6414 break;
6415 }
6416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21479608 times.
21479608 if ( do_animation )
6417 {
6418
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 21282566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21015435 times.
21479608 if(ndir!=0) switch(frames)
6419 {
6420 case 2:
6421 267131 tiledir_small(dir,ndir==4);
6422 267131 break;
6423
6424 case 3:
6425 tiledir_three(dir);
6426 break;
6427
6428 case 4:
6429 21015435 tiledir(dir,ndir==4);
6430 21015435 break;
6431 21282566 }
6432
6433
2/2
✓ Branch 0 taken 11462151 times.
✓ Branch 1 taken 10017457 times.
21479608 if(type==eeWALK)
6434
6/6
✓ Branch 0 taken 11400377 times.
✓ Branch 1 taken 61774 times.
✓ Branch 2 taken 8646924 times.
✓ Branch 3 taken 2815227 times.
✓ Branch 4 taken 2799303 times.
✓ Branch 5 taken 15924 times.
11462151 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6435 else
6436 10017457 tile+=f4;
6437 21479608 }
6438 21479608 return b;
6439 }
6440
6441 void enemy::tiledir_three(int32_t ndir)
6442 {
6443 if ( !do_animation ) return;
6444 flip=0;
6445
6446 switch(ndir)
6447 {
6448 case right:
6449 tile+=3;
6450 [[fallthrough]];
6451
6452 case left:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case down:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case up:
6461 break;
6462 }
6463 }
6464
6465 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6466 {
6467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6468 267131 flip=0;
6469
6470
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6471 {
6472 case 8:
6473 case up:
6474 53829 break;
6475
6476 case 12:
6477 case down:
6478 54679 tile+=2;
6479 54679 break;
6480
6481 case 14:
6482 case left:
6483 67727 tile+=4;
6484 67727 break;
6485
6486 case 10:
6487 case right:
6488 71182 tile+=6;
6489 71182 break;
6490
6491 case 9:
6492 case r_up:
6493
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6494 5706 break;
6495
6496 tile+=10;
6497 break;
6498
6499 case 11:
6500 case r_down:
6501
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6502 5154 tile+=2;
6503 else
6504 tile+=14;
6505
6506 5154 break;
6507
6508 case 13:
6509 case l_down:
6510
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6511 4872 tile+=2;
6512 else
6513 tile+=12;
6514
6515 4872 break;
6516
6517 case 15:
6518 case l_up:
6519
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6520 3982 break;
6521
6522 tile+=8;
6523 break;
6524
6525 default:
6526 //dir=(zc_oldrand()*100)%8;
6527 //tiledir_small(dir);
6528 // flip=zc_oldrand()&3;
6529 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6530 break;
6531 }
6532 267131 }
6533
6534 24500538 void enemy::tiledir(int32_t ndir, bool fourdir)
6535 {
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24500538 times.
24500538 if ( !do_animation ) return;
6537 24500538 flip=0;
6538
6539
9/9
✓ Branch 0 taken 4758764 times.
✓ Branch 1 taken 4413322 times.
✓ Branch 2 taken 5718471 times.
✓ Branch 3 taken 5503275 times.
✓ Branch 4 taken 882607 times.
✓ Branch 5 taken 1091633 times.
✓ Branch 6 taken 1164932 times.
✓ Branch 7 taken 897860 times.
✓ Branch 8 taken 69674 times.
24500538 switch(ndir)
6540 {
6541 case 8:
6542 case up:
6543 4758764 break;
6544
6545 case 12:
6546 case down:
6547 4413322 tile+=4;
6548 4413322 break;
6549
6550 case 14:
6551 case left:
6552 5718471 tile+=8;
6553 5718471 break;
6554
6555 case 10:
6556 case right:
6557 5503275 tile+=12;
6558 5503275 break;
6559
6560 case 9:
6561 case r_up:
6562
2/2
✓ Branch 0 taken 91176 times.
✓ Branch 1 taken 791431 times.
882607 if(fourdir)
6563 91176 break;
6564 else
6565 791431 tile+=24;
6566
6567 791431 break;
6568
6569 case 11:
6570 case r_down:
6571
2/2
✓ Branch 0 taken 103341 times.
✓ Branch 1 taken 988292 times.
1091633 if(fourdir)
6572 103341 tile+=4;
6573 else
6574 988292 tile+=32;
6575
6576 1091633 break;
6577
6578 case 13:
6579 case l_down:
6580
2/2
✓ Branch 0 taken 107670 times.
✓ Branch 1 taken 1057262 times.
1164932 if(fourdir)
6581 107670 tile+=4;
6582 else
6583 1057262 tile+=28;
6584
6585 1164932 break;
6586
6587 case 15:
6588 case l_up:
6589
2/2
✓ Branch 0 taken 87227 times.
✓ Branch 1 taken 810633 times.
897860 if(fourdir)
6590 87227 break;
6591 else
6592 810633 tile+=20;
6593
6594 810633 break;
6595
6596 default:
6597 //dir=(zc_oldrand()*100)%8;
6598 //tiledir(dir);
6599 // flip=zc_oldrand()&3;
6600 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6601 69674 break;
6602 }
6603 24500538 }
6604
6605 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6606 {
6607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6608 3868 flip=0;
6609
6610
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6611 {
6612 case 8:
6613 case up:
6614 297 break;
6615
6616 case 12:
6617 case down:
6618 tile+=8;
6619 break;
6620
6621 case 14:
6622 case left:
6623 195 tile+=40;
6624 195 break;
6625
6626 case 10:
6627 case right:
6628 179 tile+=48;
6629 179 break;
6630
6631 case 9:
6632 case r_up:
6633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6634 break;
6635
6636 306 tile+=88;
6637 306 break;
6638
6639 case 11:
6640 case r_down:
6641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6642 tile+=8;
6643 else
6644 1235 tile+=128;
6645
6646 1235 break;
6647
6648 case 13:
6649 case l_down:
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6651 tile+=8;
6652 else
6653 1324 tile+=120;
6654
6655 1324 break;
6656
6657 case 15:
6658 case l_up:
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6660 break;
6661
6662 332 tile+=80;
6663 332 break;
6664
6665 default:
6666 //dir=(zc_oldrand()*100)%8;
6667 //tiledir_big(dir);
6668 // flip=zc_oldrand()&3;
6669 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6670 break;
6671 }
6672 3868 }
6673
6674 41612879 void enemy::update_enemy_frame()
6675 {
6676
4/4
✓ Branch 0 taken 41609652 times.
✓ Branch 1 taken 3227 times.
✓ Branch 2 taken 1416 times.
✓ Branch 3 taken 41608236 times.
41612879 if(fallclk||drownclk) return;
6677
2/2
✓ Branch 0 taken 41592762 times.
✓ Branch 1 taken 15474 times.
41608236 if (!do_animation)
6678 15474 return;
6679
6680
4/4
✓ Branch 0 taken 2981941 times.
✓ Branch 1 taken 38610821 times.
✓ Branch 2 taken 2976633 times.
✓ Branch 3 taken 5308 times.
41592762 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6681
6682
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
41592762 if(get_qr(qr_ANONE_NOANIM)
6683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41592762 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
41592762 && anim == aNONE && type != eeGUY)
6684 return;
6685
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 41221386 times.
41592762 int32_t newfrate = zc_max(frate,4);
6686 41592762 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6687 41592762 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6688
2/2
✓ Branch 0 taken 31596468 times.
✓ Branch 1 taken 9996294 times.
41592762 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6689 41592762 tile = o_tile;
6690 41592762 int32_t basetile = o_tile;
6691 41592762 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6692 41592762 bool ignore_extend = false;
6693
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209447 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 379205 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5128844 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 61143 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 709864 times.
✓ Branch 22 taken 1694695 times.
✓ Branch 23 taken 1160883 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4365684 times.
✓ Branch 27 taken 7944541 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1851190 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7487838 times.
✓ Branch 37 taken 882793 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 208231 times.
41592762 switch(anim)
6694 {
6695
6696 case aDONGO:
6697 {
6698 69324 int32_t fr = stunclk>0 ? 16 : 8;
6699
6700
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6701 {
6702 // bloated
6703
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6704 {
6705 case up:
6706 960 tile+=9;
6707 960 flip=0;
6708 960 xofs=0;
6709 960 dummy_int[1]=0; //no additional tiles
6710 960 break;
6711
6712 case down:
6713 960 tile+=7;
6714 960 flip=0;
6715 960 xofs=0;
6716 960 dummy_int[1]=0; //no additional tiles
6717 960 break;
6718
6719 case left:
6720 1664 flip=1;
6721 1664 tile+=4;
6722 1664 xofs=16;
6723 1664 dummy_int[1]=1; //second tile is next tile
6724 1664 break;
6725
6726 case right:
6727 896 flip=0;
6728 896 tile+=5;
6729 896 xofs=16;
6730 896 dummy_int[1]=-1; //second tile is previous tile
6731 896 break;
6732 }
6733 4480 }
6734
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6735 {
6736 // normal
6737
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6738 {
6739 case up:
6740 13652 tile+=8;
6741 13652 flip=(clk&fr)?1:0;
6742 13652 xofs=0;
6743 13652 dummy_int[1]=0; //no additional tiles
6744 13652 break;
6745
6746 case down:
6747 15374 tile+=6;
6748 15374 flip=(clk&fr)?1:0;
6749 15374 xofs=0;
6750 15374 dummy_int[1]=0; //no additional tiles
6751 15374 break;
6752
6753 case left:
6754 19615 flip=1;
6755 19615 tile+=(clk&fr)?2:0;
6756 19615 xofs=16;
6757 19615 dummy_int[1]=1; //second tile is next tile
6758 19615 break;
6759
6760 case right:
6761 15086 flip=0;
6762 15086 tile+=(clk&fr)?3:1;
6763 15086 xofs=16;
6764 15086 dummy_int[1]=-1; //second tile is next tile
6765 15086 break;
6766 }
6767 63727 }
6768 }
6769 69324 break;
6770
6771 case aNEWDONGO:
6772 {
6773 61143 int32_t fr4=0;
6774
6775
6/6
✓ Branch 0 taken 58987 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 4704 times.
✓ Branch 3 taken 54283 times.
✓ Branch 4 taken 1568 times.
✓ Branch 5 taken 3136 times.
61143 if(!dying && clk2>0 && clk2<=64)
6776 {
6777 // bloated
6778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3136 times.
3136 if(clk2>=0)
6779 {
6780 3136 fr4=3;
6781 3136 }
6782
6783
2/2
✓ Branch 0 taken 735 times.
✓ Branch 1 taken 2401 times.
3136 if(clk2>=16)
6784 {
6785 2401 fr4=2;
6786 2401 }
6787
6788
2/2
✓ Branch 0 taken 1519 times.
✓ Branch 1 taken 1617 times.
3136 if(clk2>=32)
6789 {
6790 1617 fr4=1;
6791 1617 }
6792
6793
2/2
✓ Branch 0 taken 2303 times.
✓ Branch 1 taken 833 times.
3136 if(clk2>=48)
6794 {
6795 833 fr4=0;
6796 833 }
6797
6798
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 832 times.
✓ Branch 4 taken 1344 times.
3136 switch(dir)
6799 {
6800 case up:
6801 320 xofs=0;
6802 320 tile+=8+fr4;
6803 320 dummy_int[1]=0; //no additional tiles
6804 320 break;
6805
6806 case down:
6807 640 xofs=0;
6808 640 tile+=12+fr4;
6809 640 dummy_int[1]=0; //no additional tiles
6810 640 break;
6811
6812 case left:
6813 832 tile+=29+(2*fr4);
6814 832 xofs=16;
6815 832 dummy_int[1]=-1; //second tile is previous tile
6816 832 break;
6817
6818 case right:
6819 1344 tile+=49+(2*fr4);
6820 1344 xofs=16;
6821 1344 dummy_int[1]=-1; //second tile is previous tile
6822 1344 break;
6823 }
6824 3136 }
6825
4/4
✓ Branch 0 taken 2156 times.
✓ Branch 1 taken 55851 times.
✓ Branch 2 taken 1136 times.
✓ Branch 3 taken 1020 times.
58007 else if(!dying || clk2>19)
6826 {
6827 // normal
6828
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10376 times.
✓ Branch 2 taken 10945 times.
✓ Branch 3 taken 17524 times.
✓ Branch 4 taken 18142 times.
56987 switch(dir)
6829 {
6830 case up:
6831 10376 xofs=0;
6832 10376 tile+=((clk&12)>>2);
6833 10376 dummy_int[1]=0; //no additional tiles
6834 10376 break;
6835
6836 case down:
6837 10945 xofs=0;
6838 10945 tile+=4+((clk&12)>>2);
6839 10945 dummy_int[1]=0; //no additional tiles
6840 10945 break;
6841
6842 case left:
6843 17524 tile+=21+((clk&12)>>1);
6844 17524 xofs=16;
6845 17524 dummy_int[1]=-1; //second tile is previous tile
6846 17524 break;
6847
6848 case right:
6849 18142 flip=0;
6850 18142 tile+=41+((clk&12)>>1);
6851 18142 xofs=16;
6852 18142 dummy_int[1]=-1; //second tile is previous tile
6853 18142 break;
6854 }
6855 56987 }
6856 }
6857 61143 break;
6858
6859 case aDONGOBS:
6860 {
6861 38833 int32_t fr4=0;
6862
6863
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6864 {
6865 // bloated
6866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6867 {
6868 2688 fr4=3;
6869 2688 }
6870
6871
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6872 {
6873 2058 fr4=2;
6874 2058 }
6875
6876
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6877 {
6878 1386 fr4=1;
6879 1386 }
6880
6881
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6882 {
6883 714 fr4=0;
6884 714 }
6885
6886
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6887 {
6888 case up:
6889 256 tile+=28+fr4;
6890 256 yofs+=8;
6891 256 dummy_int[1]=-20; //second tile change
6892 256 dummy_int[2]=0; //new xofs change
6893 256 dummy_int[3]=-16; //new xofs change
6894 256 break;
6895
6896 case down:
6897 384 tile+=12+fr4;
6898 384 yofs-=8;
6899 384 dummy_int[1]=20; //second tile change
6900 384 dummy_int[2]=0; //new xofs change
6901 384 dummy_int[3]=16; //new xofs change
6902 384 break;
6903
6904 case left:
6905 1024 tile+=49+(2*fr4);
6906 1024 xofs+=8;
6907 1024 dummy_int[1]=-1; //second tile change
6908 1024 dummy_int[2]=-16; //new xofs change
6909 1024 dummy_int[3]=0; //new xofs change
6910 1024 break;
6911
6912 case right:
6913 1024 tile+=69+(2*fr4);
6914 1024 xofs+=8;
6915 1024 dummy_int[1]=-1; //second tile change
6916 1024 dummy_int[2]=-16; //new xofs change
6917 1024 dummy_int[3]=0; //new xofs change
6918 1024 break;
6919 }
6920 2688 }
6921
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6922 {
6923 // normal
6924
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6925 {
6926 case up:
6927 7136 tile+=20+((clk&24)>>3);
6928 7136 yofs+=8;
6929 7136 dummy_int[1]=-20; //second tile change
6930 7136 dummy_int[2]=0; //new xofs change
6931 7136 dummy_int[3]=-16; //new xofs change
6932 7136 break;
6933
6934 case down:
6935 6672 tile+=4+((clk&24)>>3);
6936 6672 yofs-=8;
6937 6672 dummy_int[1]=20; //second tile change
6938 6672 dummy_int[2]=0; //new xofs change
6939 6672 dummy_int[3]=16; //new xofs change
6940 6672 break;
6941
6942 case left:
6943 11075 xofs=-8;
6944 11075 tile+=40+((clk&24)>>2);
6945 11075 dummy_int[1]=1; //second tile change
6946 11075 dummy_int[2]=16; //new xofs change
6947 11075 dummy_int[3]=0; //new xofs change
6948 11075 break;
6949
6950 case right:
6951 10601 tile+=60+((clk&24)>>2);
6952 10601 xofs=-8;
6953 10601 dummy_int[1]=1; //second tile change
6954 10601 dummy_int[2]=16; //new xofs change
6955 10601 dummy_int[3]=0; //new xofs change
6956 10601 break;
6957 }
6958 35484 }
6959 }
6960 38833 break;
6961
6962 case aWIZZ:
6963 {
6964 // if(d->misc1)
6965
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6966 {
6967
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6968 {
6969 91127 ++tile;
6970 91127 }
6971 182184 }
6972 else
6973 {
6974
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6975 {
6976 136489 ++tile;
6977 136489 }
6978 }
6979
6980
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6981 {
6982 case 9:
6983 case 15:
6984 case up:
6985 76094 tile+=2;
6986 76094 break;
6987
6988 case down:
6989 76591 break;
6990
6991 case 13:
6992 case left:
6993 157108 flip=1;
6994 157108 break;
6995
6996 default:
6997 145581 flip=0;
6998 145581 break;
6999 }
7000 }
7001 455374 break;
7002
7003 case aNEWWIZZ:
7004 {
7005 1525813 tiledir(dir,true);
7006
7007 // if(d->misc1) //walking wizzrobe
7008
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7009 {
7010
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7011 {
7012 369103 tile+=2;
7013 369103 }
7014
7015
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7016 {
7017 370339 tile+=1;
7018 370339 }
7019
7020
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7021 {
7022
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7023 {
7024 79162 tile+=40;
7025 79162 }
7026 742424 }
7027 742424 }
7028 else
7029 {
7030
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7031 {
7032 235972 tile+=20;
7033
7034
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7035 {
7036 168836 tile+=20;
7037 168836 }
7038 235972 }
7039
7040 783389 tile+=((frame>>1)&3);
7041 }
7042 }
7043 1525813 break;
7044
7045 case a3FRM:
7046 {
7047
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7048 }
7049 197042 break;
7050
7051 case a3FRM4DIR:
7052 {
7053 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7054 }
7055 break;
7056
7057 case aVIRE:
7058 {
7059
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7060 {
7061 29292 tile+=2;
7062 29292 }
7063
7064 128880 tile+=fx;
7065 }
7066 128880 break;
7067
7068 case aROPE:
7069 {
7070 220021 tile+=(1-fx);
7071 220021 flip = dir==left ? 1:0;
7072 }
7073 220021 break;
7074
7075 case aZORA:
7076 {
7077 int32_t dl;
7078
7079
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7080 {
7081 46739 dl=clk+5;
7082 46739 goto waves2;
7083 }
7084
7085
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7086
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7087 else
7088 {
7089 92458 dl=clk-36-66;
7090 waves2:
7091 139197 tile=((dl/11)&1)+s_tile;
7092 139197 basetile = s_tile;
7093 }
7094 }
7095 221637 break;
7096
7097 case aNEWZORA:
7098 {
7099 709864 f4=(clk/16)%4;
7100
7101 709864 tiledir(dir,true);
7102 int32_t dl;
7103
7104
4/4
✓ Branch 0 taken 502852 times.
✓ Branch 1 taken 207012 times.
✓ Branch 2 taken 257748 times.
✓ Branch 3 taken 245104 times.
709864 if((clk>35)&&(clk<36+67)) //surfaced
7105 {
7106
4/4
✓ Branch 0 taken 209494 times.
✓ Branch 1 taken 35610 times.
✓ Branch 2 taken 30292 times.
✓ Branch 3 taken 179202 times.
245104 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7107 {
7108 179202 tile+=80;
7109 179202 } //mouth closed
7110 else
7111 {
7112 65902 tile+=40;
7113 }
7114
7115 245104 tile+=f4;
7116 245104 }
7117 else
7118 {
7119
2/2
✓ Branch 0 taken 207012 times.
✓ Branch 1 taken 257748 times.
464760 if(clk<36)
7120 {
7121 207012 dl=clk+5;
7122 207012 }
7123 else
7124 {
7125 257748 dl=clk-36-66;
7126 }
7127
7128 464760 tile+=((dl/5)&3);
7129 }
7130 }
7131 709864 break;
7132
7133 case a4FRM4EYE:
7134 case a2FRM4EYE:
7135 case a4FRM8EYE:
7136 case a4FRM8EYEB: //big version
7137 case a4FRM4EYEB:
7138 {
7139 836734 tilerows = 2;
7140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7142 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7143 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7144 836734 int32_t lookat=zc_oldrand()&15;
7145
7146
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7147 {
7148 210774 lookat=l_down;
7149 210774 }
7150
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7151 {
7152 226850 lookat=down;
7153 226850 }
7154
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7155 {
7156 108837 lookat=r_down;
7157 108837 }
7158
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7159 {
7160 70395 lookat=right;
7161 70395 }
7162
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7163 {
7164 35067 lookat=r_up;
7165 35067 }
7166
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7167 {
7168 25436 lookat=up;
7169 25436 }
7170
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7171 {
7172 36803 lookat=l_up;
7173 36803 }
7174 else
7175 {
7176 122572 lookat=left;
7177 }
7178
7179 836734 int32_t dir2 = dir;
7180 836734 dir = lookat;
7181
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7182 else
7183 {
7184 tiledir_big(dir,(anim == a4FRM4EYEB));
7185 tile+=2*f4;
7186 ignore_extend = true;
7187 }
7188 836734 dir = dir2;
7189 }
7190 836734 break;
7191
7192 case aFLIP:
7193 {
7194 1694695 flip = f2&1;
7195 }
7196 1694695 break;
7197
7198 case a2FRM:
7199 {
7200 1160883 tile += (1-f2);
7201 }
7202 1160883 break;
7203
7204 case a2FRMB:
7205 {
7206 tile+= 2*(1-f2);
7207 ignore_extend = true;
7208 }
7209 break;
7210
7211 case a2FRM4DIR:
7212 {
7213 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7214 }
7215 267131 break;
7216
7217 case a4FRM4DIRF:
7218 {
7219 4365684 basetile = n_frame_n_dir(4,4,f4);
7220
7221
2/2
✓ Branch 0 taken 2886480 times.
✓ Branch 1 taken 1479204 times.
4365684 if(clk2>0) //stopped to fire
7222 {
7223 1479204 tile+=20;
7224
7225
2/2
✓ Branch 0 taken 744443 times.
✓ Branch 1 taken 734761 times.
1479204 if(clk2<17) //firing
7226 {
7227 734761 tile+=20;
7228 734761 }
7229 1479204 }
7230 }
7231 4365684 break;
7232
7233 case a4FRM4DIR:
7234 {
7235 7944541 basetile = n_frame_n_dir(4,4,f4);
7236 }
7237 7944541 break;
7238
7239 case a4FRM8DIRF:
7240 {
7241 tilerows = 2;
7242 basetile = n_frame_n_dir(4,8,f4);
7243
7244 if(clk2>0) //stopped to fire
7245 {
7246 tile+=40;
7247
7248 if(clk2<17) //firing
7249 {
7250 tile+=40;
7251 }
7252 }
7253 }
7254 break;
7255
7256 case a4FRM8DIRB:
7257 case a4FRM8DIRFB:
7258 {
7259 3868 tilerows = 2;
7260 3868 tiledir_big(dir,false);
7261 3868 tile+=2*f4;
7262
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7263 {
7264 tile+=80;
7265
7266 if(clk2<17) //firing
7267 {
7268 tile+=80;
7269 }
7270 }
7271 3868 ignore_extend = true;
7272 }
7273 3868 break;
7274
7275 case a4FRM4DIRB:
7276 case a4FRM4DIRFB:
7277 {
7278 tilerows = 2;
7279 tiledir_big(dir,true);
7280 tile+=2*f4;
7281 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7282 {
7283 tile+=40;
7284
7285 if(clk2<17) //firing
7286 {
7287 tile+=40;
7288 }
7289 }
7290 ignore_extend = true;
7291 }
7292 break;
7293
7294 case aOCTO:
7295 {
7296
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7297 {
7298 case up:
7299 122459 flip = 2;
7300 122459 break;
7301
7302 case down:
7303 133448 flip = 0;
7304 133448 break;
7305
7306 case left:
7307 165651 flip = 0;
7308 165651 tile += 2;
7309 165651 break;
7310
7311 case right:
7312 157227 flip = 1;
7313 157227 tile += 2;
7314 157227 break;
7315 }
7316
7317 582937 tile+=f2;
7318 }
7319 582937 break;
7320
7321 case aWALK:
7322 {
7323
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7324 {
7325 case up:
7326 248704 tile+=3;
7327 248704 flip = f2;
7328 248704 break;
7329
7330 case down:
7331 267165 tile+=2;
7332 267165 flip = f2;
7333 267165 break;
7334
7335 case left:
7336 331694 flip=1;
7337 331694 tile += f2;
7338 331694 break;
7339
7340 case right:
7341 325802 flip=0;
7342 325802 tile += f2;
7343 325802 break;
7344 }
7345 }
7346 1178979 break;
7347
7348 case aDWALK:
7349 {
7350
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7351 {
7352 tile=s_tile;
7353 basetile = s_tile;
7354 }
7355
7356
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7357 {
7358 case up:
7359 177728 tile+=2;
7360 177728 flip=f2;
7361 177728 break;
7362
7363 case down:
7364 185581 flip=0;
7365 185581 tile+=(1-f2);
7366 185581 break;
7367
7368 case left:
7369 260885 flip=1;
7370 260885 tile+=(3+f2);
7371 260885 break;
7372
7373 case right:
7374 255982 flip=0;
7375 255982 tile+=(3+f2);
7376 255982 break;
7377 }
7378 }
7379 880176 break;
7380
7381 case aTEK:
7382 {
7383
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7384 {
7385 79120 tile += f2;
7386 79120 }
7387
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7388 {
7389 66827 ++tile;
7390 66827 }
7391 }
7392 219096 break;
7393
7394 case aNEWTEK:
7395 {
7396
2/2
✓ Branch 0 taken 486344 times.
✓ Branch 1 taken 1364846 times.
1851190 if(step<0) //up
7397 {
7398
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 241422 times.
✓ Branch 2 taken 244922 times.
486344 switch(clk3)
7399 {
7400 case left:
7401 241422 flip=0;
7402 241422 tile+=20;
7403 241422 break;
7404
7405 case right:
7406 244922 flip=0;
7407 244922 tile+=24;
7408 244922 break;
7409 }
7410 486344 }
7411
2/2
✓ Branch 0 taken 55855 times.
✓ Branch 1 taken 1308991 times.
1364846 else if(step==0)
7412 {
7413
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 41297 times.
✓ Branch 2 taken 14558 times.
55855 switch(clk3)
7414 {
7415 case left:
7416 41297 flip=0;
7417 41297 tile+=8;
7418 41297 break;
7419
7420 case right:
7421 14558 flip=0;
7422 14558 tile+=12;
7423 14558 break;
7424 }
7425 55855 } //down
7426 else
7427 {
7428
3/3
✓ Branch 0 taken 109422 times.
✓ Branch 1 taken 602693 times.
✓ Branch 2 taken 596876 times.
1308991 switch(clk3)
7429 {
7430 case left:
7431 602693 flip=0;
7432 602693 tile+=28;
7433 602693 break;
7434
7435 case right:
7436 596876 flip=0;
7437 596876 tile+=32;
7438 596876 break;
7439 }
7440 }
7441
7442
2/2
✓ Branch 0 taken 1263790 times.
✓ Branch 1 taken 587400 times.
1851190 if(misc==0)
7443 {
7444 587400 tile+=f4;
7445 587400 }
7446
2/2
✓ Branch 0 taken 591200 times.
✓ Branch 1 taken 672590 times.
1263790 else if(misc!=1)
7447 {
7448 672590 tile+=2;
7449 672590 }
7450 }
7451 1851190 break;
7452
7453 case aARMOS:
7454 {
7455
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7456 {
7457 5401 tile += fx;
7458
7459
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7460 1197 tile += 2;
7461 5401 }
7462 }
7463 8628 break;
7464
7465 case aARMOS4:
7466 {
7467
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29180 times.
✓ Branch 2 taken 92750 times.
✓ Branch 3 taken 43787 times.
✓ Branch 4 taken 43280 times.
209447 switch(dir)
7468 {
7469 case up:
7470 29180 flip=0;
7471 29180 break;
7472
7473 case down:
7474 92750 flip=0;
7475 92750 tile+=4;
7476 92750 break;
7477
7478 case left:
7479 43787 flip=0;
7480 43787 tile+=8;
7481 43787 break;
7482
7483 case right:
7484 43280 flip=0;
7485 43280 tile+=12;
7486 43280 break;
7487 }
7488
7489
2/2
✓ Branch 0 taken 63277 times.
✓ Branch 1 taken 146170 times.
209447 if(!fading)
7490 {
7491 146170 tile+=f4;
7492 146170 }
7493 }
7494 209447 break;
7495
7496 case aGHINI:
7497 {
7498
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7499 {
7500 case 8:
7501 case 9:
7502 case up:
7503 28037 ++tile;
7504 28037 flip=0;
7505 28037 break;
7506
7507 case 15:
7508 452 ++tile;
7509 452 flip=1;
7510 452 break;
7511
7512 case 10:
7513 case 11:
7514 case right:
7515 32092 flip=1;
7516 32092 break;
7517
7518 default:
7519 72763 flip=0;
7520 72763 break;
7521 }
7522 }
7523 133344 break;
7524
7525 case a2FRMPOS:
7526 {
7527 1755010 tile+=posframe;
7528 }
7529 1755010 break;
7530
7531 case a4FRMPOS4DIR:
7532 {
7533 379205 basetile = n_frame_n_dir(4,4,0);
7534 // tile+=f2;
7535 379205 tile+=posframe;
7536 }
7537 379205 break;
7538
7539 case a4FRMPOS4DIRF:
7540 {
7541 1433 basetile = n_frame_n_dir(4,4,0);
7542
7543
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7544 {
7545 197 tile+=20;
7546
7547
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7548 {
7549 64 tile+=20;
7550 64 }
7551 197 }
7552
7553 // tile+=f2;
7554 1433 tile+=posframe;
7555 }
7556 1433 break;
7557
7558 case a4FRMPOS8DIR:
7559 {
7560 7487838 tilerows = 2;
7561 7487838 int32_t n = tile;
7562 7487838 basetile = n_frame_n_dir(4,8,0);
7563 // tile+=f2;
7564 7487838 tile+=posframe;
7565 }
7566 7487838 break;
7567
7568 case a4FRMPOS8DIRF:
7569 {
7570 tilerows = 2;
7571 basetile = n_frame_n_dir(4,8,0);
7572
7573 if(clk2>0) //stopped to fire
7574 {
7575 tile+=40;
7576
7577 if(clk2<17) //firing
7578 {
7579 tile+=40;
7580 }
7581 }
7582
7583 tile+=posframe;
7584 }
7585 break;
7586
7587 case aNEWLEV:
7588 {
7589 882793 tiledir(dir,true);
7590
7591
4/5
✓ Branch 0 taken 288692 times.
✓ Branch 1 taken 139520 times.
✓ Branch 2 taken 58900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 395681 times.
882793 switch(misc)
7592 {
7593 case -1:
7594 case 0:
7595 288692 return;
7596
7597 case 1:
7598
7599 // case 5: cs = d->misc2; break;
7600 case 5:
7601 139520 cs = dmisc2;
7602 139520 break;
7603
7604 case 2:
7605 case 4:
7606 58900 tile += 20;
7607 58900 break;
7608
7609 case 3:
7610 395681 tile += 40;
7611 395681 break;
7612 }
7613
7614 594101 tile+=f4;
7615 }
7616 594101 break;
7617
7618 case aLEV:
7619 {
7620 276997 f4 = ((clk/5)&1);
7621
7622
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7623 {
7624 case -1:
7625 case 0:
7626 127945 return;
7627
7628 case 1:
7629
7630 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7631 case 5:
7632 33336 tile += (f2) ? 1 : 0;
7633 33336 cs = dmisc2;
7634 33336 break;
7635
7636 case 2:
7637 case 4:
7638 14658 tile += 2;
7639 14658 break;
7640
7641 case 3:
7642 101058 tile += (f4) ? 4 : 3;
7643 101058 break;
7644 }
7645 }
7646 149052 break;
7647
7648 case aWALLM:
7649 {
7650
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7651 {
7652 139764 tile += f2;
7653 139764 }
7654 }
7655 140514 break;
7656
7657 case aNEWWALLM:
7658 {
7659 366633 int32_t tempdir=0;
7660
7661
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7662 {
7663 case 1:
7664 case 2:
7665 43340 tempdir=clk3;
7666 43340 break;
7667
7668 case 3:
7669 case 4:
7670 case 5:
7671 38855 tempdir=dir;
7672 38855 break;
7673
7674 case 6:
7675 case 7:
7676 8438 tempdir=clk3^1;
7677 8438 break;
7678 }
7679
7680 366633 tiledir(tempdir,true);
7681
7682
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7683 {
7684 364725 tile+=f4;
7685 364725 }
7686 }
7687 366633 break;
7688
7689 case a4FRMNODIR:
7690 {
7691 208231 tile+=f4;
7692 }
7693 208231 break;
7694
7695 } // switch(d->anim)
7696
7697 // flashing
7698 // if(d->flags & guy_flashing)
7699
2/2
✓ Branch 0 taken 40428576 times.
✓ Branch 1 taken 747549 times.
41176125 if(flags & guy_flashing)
7700 {
7701 747549 cs = (frame&3) + 6;
7702 747549 }
7703
7704
2/2
✓ Branch 0 taken 40749717 times.
✓ Branch 1 taken 426408 times.
41176125 if(flags&guy_transparent)
7705 {
7706 426408 drawstyle=1;
7707 426408 }
7708
7709 41176125 int32_t change = tile-basetile;
7710
7711
3/6
✓ Branch 0 taken 2100068 times.
✓ Branch 1 taken 39076057 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2100068 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
41176125 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7712 {
7713
2/2
✓ Branch 0 taken 1817749 times.
✓ Branch 1 taken 282319 times.
2100068 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7714 {
7715 1817749 tile=basetile+txsz*change;
7716 1817749 }
7717 else
7718 {
7719 282319 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7720 }
7721 2100068 }
7722 else
7723 {
7724 39076057 tile=basetile+change;
7725 }
7726 41612879 }
7727
7728 82778 int32_t enemy::wpnsfx(int32_t wpn)
7729 {
7730
3/3
✓ Branch 0 taken 22655 times.
✓ Branch 1 taken 41540 times.
✓ Branch 2 taken 18583 times.
82778 switch (wpn)
7731 {
7732 case wScript1:
7733 case wScript2:
7734 case wScript3:
7735 case wScript4:
7736 case wScript5:
7737 case wScript6:
7738 case wScript7:
7739 case wScript8:
7740 case wScript9:
7741 case wScript10: //sure why not
7742 case ewFireTrail:
7743 case ewFlame:
7744 case ewFlame2Trail:
7745 case ewFlame2:
7746 case ewWind:
7747 case ewMagic:
7748 case ewIce:
7749 22655 return firesfx;
7750
7751 case ewRock:
7752 case ewFireball2:
7753 case ewFireball:
7754
2/2
✓ Branch 0 taken 6082 times.
✓ Branch 1 taken 35458 times.
41540 if (get_qr(qr_MORESOUNDS)) return firesfx;
7755 35458 break;
7756 }
7757
7758 54041 return 0;
7759 82778 }
7760
7761 79108729 int32_t enemy::run_script(int32_t mode)
7762 {
7763 void push_ri();
7764 void pop_ri();
7765
7766
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 79108473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
79108729 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7767
4/6
✓ Branch 0 taken 230366 times.
✓ Branch 1 taken 78878107 times.
✓ Branch 2 taken 230366 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 230366 times.
79108473 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7768 78878107 return RUNSCRIPT_OK;
7769 230366 auto scrty = *get_scrtype();
7770 230366 auto uid = getUID();
7771
1/2
✓ Branch 0 taken 230366 times.
✗ Branch 1 not taken.
230366 if(!FFCore.doscript(scrty,uid))
7772 return RUNSCRIPT_OK;
7773 230366 int32_t ret = RUNSCRIPT_OK;
7774 230366 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7775 230366 push_ri();
7776
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 111621 times.
✓ Branch 2 taken 118745 times.
230366 switch(mode)
7777 {
7778 case MODE_NORMAL:
7779 111621 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7780 111621 break;
7781
7782 case MODE_WAITDRAW:
7783
1/2
✓ Branch 0 taken 118745 times.
✗ Branch 1 not taken.
118745 if(waitdraw)
7784 {
7785 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7786 waitdraw = false;
7787 }
7788 118745 break;
7789 }
7790 230366 pop_ri();
7791 230366 return ret;
7792 79108729 }
7793 5247 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7794 {
7795 5247 return al_map_rgba(255,0,0,opacity);
7796 }
7797
7798 // good guys, fires, fairy, and other non-enemies
7799 // based on enemy class b/c guys in dungeons act sort of like enemies
7800 // also easier to manage all the guys this way
7801 2198 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7802 2198 {
7803 2198 mainguy=mg;
7804 2198 canfreeze=false;
7805 2198 dir=down;
7806
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2198 times.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
2198 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7807 2198 hxofs=2;
7808 2198 hzsz=8;
7809 2198 hit_width=12;
7810 2198 hit_height=17;
7811
7812
10/12
✓ Branch 0 taken 2198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1433 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2198 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7813 {
7814 1938 superman = 1;
7815 1938 hxofs=1000;
7816 1938 }
7817 2198 }
7818
7819 945874 bool guy::animate(int32_t index)
7820 {
7821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945874 times.
945874 if(switch_hooked) return enemy::animate(index);
7822
6/6
✓ Branch 0 taken 545304 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8309 times.
✓ Branch 3 taken 536995 times.
✓ Branch 4 taken 7096 times.
✓ Branch 5 taken 1213 times.
945874 if(mainguy && clk==0 && misc==0)
7823 {
7824 1213 setupscreen();
7825 1213 misc = 1;
7826 1213 }
7827
7828
4/4
✓ Branch 0 taken 545304 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 544974 times.
✓ Branch 3 taken 330 times.
945874 if(mainguy && fadeclk==0)
7829 330 return true;
7830
7831 945544 hp=256; // good guys never die...
7832
7833
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 944622 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
945544 if(hclk && !clk2)
7834 {
7835 // but if they get hit...
7836 16 ++clk2; // only do this once
7837
7838
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7839 {
7840 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7841 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7842 7 }
7843 16 }
7844
7845 945544 return enemy::animate(index);
7846 945874 }
7847
7848 949646 void guy::draw(BITMAP *dest)
7849 {
7850 949646 update_enemy_frame();
7851
7852
6/6
✓ Branch 0 taken 548867 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 525956 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
949646 if(!mainguy || fadeclk<0 || fadeclk&1)
7853 937799 enemy::draw(dest);
7854 949646 }
7855
7856 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7857 760 {
7858 760 clk4=0;
7859
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7860 // Spawn type
7861
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7862 {
7863 clk=0;
7864 superman = 1;
7865 fading=fade_flicker;
7866 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7867 dir=down;
7868
7869 if(!canmove(down,(zfix)8,spw_none,false))
7870 clk3=int32_t(13.0/step);
7871 }
7872
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7873 {
7874 84 clk=0;
7875 84 }
7876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7877 760 }
7878
7879 167472 bool eFire::animate(int32_t index)
7880 {
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7882
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7883
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7884 {
7885
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7886 {
7887 1 clk4=0;
7888 1 superman=0;
7889 1 fading=0;
7890
7891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7892 removearmos(x,y);
7893
7894 1 clk2=0;
7895
7896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7897 {
7898 1 dir=0;
7899 1 y = TRUNCATE_TILE(y.getInt());
7900 1 }
7901
7902 1 return Dead(index);
7903 }
7904
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7905 removearmos(x,y);
7906 1715 }
7907
7908 167471 return enemy::animate(index);
7909 167472 }
7910
7911 351659 void eFire::draw(BITMAP *dest)
7912 {
7913 351659 update_enemy_frame();
7914 351659 enemy::draw(dest);
7915 351659 }
7916
7917 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7918 {
7919 415 int32_t wpnId = w->id;
7920 415 int32_t wpnDir = w->dir;
7921
7922
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7923 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7924 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7925 {
7926 shield = false;
7927 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7928
7929 if(get_qr(qr_BRKNSHLDTILES))
7930 o_tile=s_tile;
7931 }
7932
7933 415 int32_t ret = enemy::takehit(w,realweap);
7934 415 return ret;
7935 }
7936
7937 void eFire::break_shield()
7938 {
7939 if(!shield)
7940 return;
7941
7942 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7943 shield=false;
7944
7945 if(get_qr(qr_BRKNSHLDTILES))
7946 o_tile=s_tile;
7947 }
7948
7949 void eFire::repair_shield()
7950 {
7951 if (shield)
7952 return;
7953
7954 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7955 return;
7956
7957 shield = true;
7958
7959 if (get_qr(qr_BRKNSHLDTILES))
7960 {
7961 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7962 else o_tile = d->tile;
7963 }
7964 }
7965
7966 7780 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7967 7780 {
7968 7780 clk4=0;
7969
4/8
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7780 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7780 times.
✗ Branch 7 not taken.
7780 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7970
7971 // Spawn type
7972
2/4
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7780 times.
7780 if(flags & guy_fade_flicker)
7973 {
7974 clk=0;
7975 superman = 1;
7976 fading=fade_flicker;
7977 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7978 dir=down;
7979
7980 if(!canmove(down,(zfix)8,spw_none,false))
7981 clk3=int32_t(13.0/step);
7982 }
7983
3/4
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6587 times.
✓ Branch 3 taken 1193 times.
7780 else if(flags & guy_fade_instant)
7984 {
7985 1193 clk=0;
7986 1193 }
7987
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7745 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
7780 if (SIZEflags != 0) init_size_flags();;
7988 7780 }
7989
7990 2069428 bool eOther::animate(int32_t index)
7991 {
7992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2069428 times.
2069428 if(switch_hooked) return enemy::animate(index);
7993
4/4
✓ Branch 0 taken 2067842 times.
✓ Branch 1 taken 1586 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 2067777 times.
2069428 if(fallclk||drownclk) return enemy::animate(index);
7994
2/2
✓ Branch 0 taken 2059241 times.
✓ Branch 1 taken 8536 times.
2067777 if(fading)
7995 {
7996
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
7997 {
7998 29 clk4=0;
7999 29 superman=0;
8000 29 fading=0;
8001
8002
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8003 removearmos(x,y);
8004
8005 29 clk2=0;
8006
8007
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8008 {
8009 2 dir=0;
8010 2 y = TRUNCATE_TILE(y.getInt());
8011 2 }
8012
8013 29 return Dead(index);
8014 }
8015
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8016 removearmos(x,y);
8017 8507 }
8018
8019 2067748 return enemy::animate(index);
8020 2069428 }
8021
8022 2202629 void eOther::draw(BITMAP *dest)
8023 {
8024 2202629 update_enemy_frame();
8025 2202629 enemy::draw(dest);
8026 2202629 }
8027
8028 15414 int32_t eOther::takehit(weapon *w, weapon* realweap)
8029 {
8030 15414 int32_t wpnId = w->id;
8031 15414 int32_t wpnDir = w->dir;
8032
8033
4/4
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 15323 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 75 times.
15414 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8034
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8035 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8036 {
8037 shield = false;
8038 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8039
8040 if(get_qr(qr_BRKNSHLDTILES))
8041 o_tile=s_tile;
8042 }
8043
8044 15414 int32_t ret = enemy::takehit(w,realweap);
8045 15414 return ret;
8046 }
8047
8048 3 void eOther::break_shield()
8049 {
8050
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!shield)
8051 return;
8052
8053 3 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8054 3 shield=false;
8055
8056
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_qr(qr_BRKNSHLDTILES))
8057 3 o_tile=s_tile;
8058 3 }
8059
8060 void eOther::repair_shield()
8061 {
8062 if (shield)
8063 return;
8064
8065 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8066 return;
8067
8068 shield = true;
8069
8070 if (get_qr(qr_BRKNSHLDTILES))
8071 {
8072 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8073 else o_tile = d->tile;
8074 }
8075 }
8076
8077 30 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8078 30 {
8079 30 clk4=0;
8080
4/8
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✗ Branch 7 not taken.
30 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8081
8082 // Spawn type
8083
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
30 if(flags & guy_fade_flicker)
8084 {
8085 clk=0;
8086 superman = 1;
8087 fading=fade_flicker;
8088 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8089 dir=down;
8090
8091 if(!canmove(down,(zfix)8,spw_none,false))
8092 clk3=int32_t(13.0/step);
8093 }
8094
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 else if(flags & guy_fade_instant)
8095 {
8096 clk=0;
8097 }
8098
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
30 if (SIZEflags != 0) init_size_flags();;
8099 30 }
8100
8101 33693 bool eScript::animate(int32_t index)
8102 {
8103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33693 times.
33693 if(switch_hooked) return enemy::animate(index);
8104
2/4
✓ Branch 0 taken 33693 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33693 times.
33693 if(fallclk||drownclk) return enemy::animate(index);
8105
1/2
✓ Branch 0 taken 33693 times.
✗ Branch 1 not taken.
33693 if(fading)
8106 {
8107 if(++clk4 > 60)
8108 {
8109 clk4=0;
8110 superman=0;
8111 fading=0;
8112
8113 if(flags&guy_armos && z==0 && fakez==0)
8114 removearmos(x,y);
8115
8116 clk2=0;
8117
8118 if(!canmove(down,(zfix)8,spw_none,false))
8119 {
8120 dir=0;
8121 y = TRUNCATE_TILE(y.getInt());
8122 }
8123
8124 return Dead(index);
8125 }
8126 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8127 removearmos(x,y);
8128 }
8129
8130 33693 return enemy::animate(index);
8131 33693 }
8132
8133 41448 void eScript::draw(BITMAP *dest)
8134 {
8135 41448 update_enemy_frame();
8136 41448 enemy::draw(dest);
8137 41448 }
8138
8139 4997 int32_t eScript::takehit(weapon *w, weapon* realweap)
8140 {
8141 4997 int32_t wpnId = w->id;
8142 4997 int32_t wpnDir = w->dir;
8143
8144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4997 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8145 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8146 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8147 {
8148 shield = false;
8149 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8150
8151 if(get_qr(qr_BRKNSHLDTILES))
8152 o_tile=s_tile;
8153 }
8154
8155 4997 int32_t ret = enemy::takehit(w,realweap);
8156 4997 return ret;
8157 }
8158
8159 void eScript::break_shield()
8160 {
8161 if(!shield)
8162 return;
8163
8164 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8165 shield=false;
8166
8167 if(get_qr(qr_BRKNSHLDTILES))
8168 o_tile=s_tile;
8169 }
8170
8171 void eScript::repair_shield()
8172 {
8173 if (shield)
8174 return;
8175
8176 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8177 return;
8178
8179 shield = true;
8180
8181 if (get_qr(qr_BRKNSHLDTILES))
8182 {
8183 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8184 else o_tile = d->tile;
8185 }
8186 }
8187
8188
8189 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8190 {
8191 clk4=0;
8192 hyofs = -32768; //No hitbox initially.
8193 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8194
8195 // Spawn type
8196 if(flags & guy_fade_flicker)
8197 {
8198 clk=0;
8199 superman = 1;
8200 fading=fade_flicker;
8201 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8202 dir=down;
8203
8204 if(!canmove(down,(zfix)8,spw_none,false))
8205 clk3=int32_t(13.0/step);
8206 }
8207 else if(flags & guy_fade_instant)
8208 {
8209 clk=0;
8210 }
8211 if (SIZEflags != 0) init_size_flags();;
8212 }
8213
8214 bool eFriendly::animate(int32_t index)
8215 {
8216 if(switch_hooked) return enemy::animate(index);
8217 if(fallclk||drownclk) return enemy::animate(index);
8218 if(fading)
8219 {
8220 if(++clk4 > 60)
8221 {
8222 clk4=0;
8223 superman=0;
8224 fading=0;
8225
8226 if(flags&guy_armos && z==0 && fakez==0)
8227 removearmos(x,y);
8228
8229 clk2=0;
8230
8231 if(!canmove(down,(zfix)8,spw_none,false))
8232 {
8233 dir=0;
8234 y = TRUNCATE_TILE(y.getInt());
8235 }
8236
8237 return Dead(index);
8238 }
8239 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8240 removearmos(x,y);
8241 }
8242
8243 return enemy::animate(index);
8244 }
8245
8246 void eFriendly::draw(BITMAP *dest)
8247 {
8248 update_enemy_frame();
8249 enemy::draw(dest);
8250 }
8251
8252 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8253 {
8254 int32_t wpnId = w->id;
8255 int32_t wpnDir = w->dir;
8256
8257 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8258 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8259 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8260 {
8261 shield = false;
8262 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8263
8264 if(get_qr(qr_BRKNSHLDTILES))
8265 o_tile=s_tile;
8266 }
8267
8268 int32_t ret = enemy::takehit(w,realweap);
8269 return ret;
8270 }
8271
8272 void eFriendly::break_shield()
8273 {
8274 if(!shield)
8275 return;
8276
8277 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8278 shield=false;
8279
8280 if(get_qr(qr_BRKNSHLDTILES))
8281 o_tile=s_tile;
8282 }
8283
8284 void eFriendly::repair_shield()
8285 {
8286 if (shield)
8287 return;
8288
8289 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8290 return;
8291
8292 shield = true;
8293
8294 if (get_qr(qr_BRKNSHLDTILES))
8295 {
8296 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8297 else o_tile = d->tile;
8298 }
8299 }
8300
8301
8302 790429 void enemy::removearmos(int32_t ax,int32_t ay)
8303 {
8304
2/2
✓ Branch 0 taken 789407 times.
✓ Branch 1 taken 1022 times.
790429 if(did_armos)
8305 789407 return;
8306 1022 did_armos=true;
8307 1022 auto handle = activated_handle;
8308
8309
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 700 times.
1022 auto layer = handle ? handle->layer() : 0;
8310
3/4
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 700 times.
✓ Branch 2 taken 322 times.
✗ Branch 3 not taken.
1022 if (!handle || handle->is_rpos())
8311 1022 handle = get_rpos_handle_for_world_xy(ax, ay, layer);
8312 1022 mapscr* scr = handle->get_mapscr();
8313
8314 1384 auto [tx, ty] = handle->xy();
8315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1022 times.
1022 if (handle->is_rpos())
8316 {
8317 2044 tx = TRUNCATE_TILE(ax);
8318 2044 ty = TRUNCATE_TILE(ay);
8319 1022 }
8320
8321 1022 int32_t f = handle->sflag();
8322 1022 int32_t f2 = handle->cflag();
8323
8324
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 178 times.
1022 if (handle->ctype() != cARMOS)
8325 844 return;
8326
8327
8328
3/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 156 times.
178 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8329 {
8330 22 handle->set_data(scr->secretcombo[sSTAIRS]);
8331 22 handle->set_cset(scr->secretcset[sSTAIRS]);
8332 22 handle->set_sflag(scr->secretflag[sSTAIRS]);
8333 22 sfx(scr->secretsfx);
8334 22 }
8335 else
8336 {
8337 156 handle->set_data(scr->undercombo);
8338 156 handle->set_cset(scr->undercset);
8339 156 handle->set_sflag(0);
8340 }
8341
8342
3/4
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
178 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8343 {
8344
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8345 {
8346 6 additem(tx,ty,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8347 3 sfx(scr->secretsfx);
8348 3 }
8349 3 }
8350
8351 534 putcombo(scrollbuf,tx,ty,handle->data(),handle->cset());
8352 790429 }
8353
8354 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8355 461 {
8356 461 fading=fade_flicker;
8357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8358 461 dir=12;
8359 461 movestatus=1;
8360
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8361 461 clk=0;
8362 461 clk4=0;
8363
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8364 461 }
8365
8366 117025 bool eGhini::animate(int32_t index)
8367 {
8368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8369
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8370
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8371 50 return Dead(index);
8372
8373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8374 {
8375
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8376 {
8377
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8378 54853 misc=2;
8379
8380
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8381 89752 removearmos(x,y);
8382 89752 }
8383
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8384 {
8385 425 misc=1;
8386 425 clk3=32;
8387 425 fading=0;
8388
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 285 times.
425 if (activated_handle)
8389 {
8390 140 activation_counters[activated_handle->layer()][activated_handle->id()] = 0;
8391 140 removearmos(x, y);
8392 140 }
8393 else
8394 {
8395 285 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8396
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if (rpos != rpos_t::None)
8397 {
8398 285 activation_counters[0][int(rpos)] = 0;
8399 285 removearmos(x,y);
8400 285 }
8401 }
8402 425 }
8403 116975 }
8404
8405 116975 clk4++;
8406
8407 116975 return enemy::animate(index);
8408 117025 }
8409
8410 238808 void eGhini::draw(BITMAP *dest)
8411 {
8412 238808 update_enemy_frame();
8413 238808 enemy::draw(dest);
8414 238808 }
8415
8416 2 void eGhini::kickbucket()
8417 {
8418 2 hp=-1000; // don't call death_sfx()
8419 2 }
8420
8421
2/4
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5303 times.
✗ Branch 3 not taken.
10606 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8422 5303 {
8423
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 old_y=y;
8424 5303 dir=down;
8425 5303 misc=1;
8426 5303 clk=-15;
8427
8428
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2654 times.
5303 if(!BSZ)
8429
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8430
8431 // avoid divide by 0 errors
8432
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 if(dmisc1 == 0)
8433 dmisc1 = 24;
8434
8435
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 if(dmisc2 == 0)
8436 dmisc2 = 3;
8437
8438 //nets+760;
8439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5303 if (SIZEflags != 0) init_size_flags();;
8440 5303 }
8441
8442 1450669 bool eTektite::animate(int32_t index)
8443 {
8444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1450669 times.
1450669 if(switch_hooked) return enemy::animate(index);
8445
4/4
✓ Branch 0 taken 1439215 times.
✓ Branch 1 taken 11454 times.
✓ Branch 2 taken 11454 times.
✓ Branch 3 taken 1437953 times.
1450669 if(fallclk||drownclk) return enemy::animate(index);
8446
2/2
✓ Branch 0 taken 26967 times.
✓ Branch 1 taken 1410986 times.
1437953 if(dying)
8447 26967 return Dead(index);
8448
8449
2/2
✓ Branch 0 taken 1373549 times.
✓ Branch 1 taken 37437 times.
1410986 if(clk==0)
8450 {
8451 37437 removearmos(x,y);
8452 37437 }
8453
8454
2/2
✓ Branch 0 taken 1058532 times.
✓ Branch 1 taken 352454 times.
1410986 if(get_qr(qr_ENEMIESZAXIS))
8455 {
8456 352454 y=floor_y;
8457 352454 }
8458
8459
9/10
✓ Branch 0 taken 1294828 times.
✓ Branch 1 taken 116158 times.
✓ Branch 2 taken 1281264 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1281264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1270088 times.
✓ Branch 8 taken 10820 times.
✓ Branch 9 taken 21996 times.
1410986 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8460 {
8461
4/4
✓ Branch 0 taken 20378 times.
✓ Branch 1 taken 424353 times.
✓ Branch 2 taken 348142 times.
✓ Branch 3 taken 499211 times.
1292084 switch(misc)
8462 {
8463 case 0: // normal
8464
2/2
✓ Branch 0 taken 413019 times.
✓ Branch 1 taken 11334 times.
424353 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8465 {
8466 11334 misc=1;
8467 11334 clk2=32;
8468 11334 }
8469
8470 424353 break;
8471
8472 case 1: // waiting to pounce
8473
2/2
✓ Branch 0 taken 327278 times.
✓ Branch 1 taken 20864 times.
348142 if(--clk2<=0)
8474 {
8475 20864 int32_t r=zc_oldrand();
8476 20864 misc=2;
8477 20864 step=0-(zslongToFix(dstep*100)); // initial speed
8478 20864 clk3=(r&1)+2; // left or right
8479 20864 clk2start=clk2=(r&31)+10; // flight time
8480
8481
2/2
✓ Branch 0 taken 18419 times.
✓ Branch 1 taken 2445 times.
20864 if(y<32) clk2+=2; // make them come down from top of screen
8482
8483
2/2
✓ Branch 0 taken 15914 times.
✓ Branch 1 taken 4950 times.
20864 if(y>world_h-64) clk2-=2; // make them go back up
8484
8485 20864 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8486 20864 }
8487
8488 348142 break;
8489
8490 case 2: // in flight
8491 499211 move(step);
8492
8493
2/2
✓ Branch 0 taken 236916 times.
✓ Branch 1 taken 262295 times.
499211 if(step>0) //going down
8494 {
8495
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 236284 times.
236916 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8496 {
8497 632 step=0-step;
8498 632 }
8499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236284 times.
236284 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8500 {
8501 step=0-step;
8502 }
8503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236284 times.
236284 else if(ispitfall(x+8,y+16))
8504 {
8505 step=0-step;
8506 }
8507
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 236237 times.
236284 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8508 {
8509 47 step=0-step;
8510 47 }
8511
2/2
✓ Branch 0 taken 236226 times.
✓ Branch 1 taken 11 times.
236237 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8512 {
8513 11 step=0-step;
8514 11 }
8515 236916 }
8516
2/2
✓ Branch 0 taken 15350 times.
✓ Branch 1 taken 246945 times.
262295 else if(step<0)
8517 {
8518
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 246507 times.
246945 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8519 {
8520 438 step=0-step;
8521 438 }
8522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246507 times.
246507 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8523 {
8524 step=0-step;
8525 }
8526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246507 times.
246507 else if(ispitfall(x+8,y))
8527 {
8528 step=0-step;
8529 }
8530
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 246486 times.
246507 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8531 {
8532 21 step=0-step;
8533 21 }
8534
2/2
✓ Branch 0 taken 246467 times.
✓ Branch 1 taken 19 times.
246486 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8535 {
8536 19 step=0-step;
8537 19 }
8538 246945 }
8539
8540
2/2
✓ Branch 0 taken 247071 times.
✓ Branch 1 taken 252140 times.
499211 if(clk3==left)
8541 {
8542
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 246796 times.
247071 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8543 {
8544 275 clk3^=1;
8545 275 }
8546
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 246790 times.
246796 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8547 {
8548 6 clk3^=1;
8549 6 }
8550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246790 times.
246790 else if(ispitfall(x,y+8))
8551 {
8552 clk3^=1;
8553 }
8554
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 246760 times.
246790 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8555 {
8556 30 clk3^=1;
8557 30 }
8558
2/2
✓ Branch 0 taken 246748 times.
✓ Branch 1 taken 12 times.
246760 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8559 {
8560 12 clk3^=1;
8561 12 }
8562 247071 }
8563 else
8564 {
8565
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 251864 times.
252140 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8566 {
8567 276 clk3^=1;
8568 276 }
8569
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 251852 times.
251864 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8570 {
8571 12 clk3^=1;
8572 12 }
8573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251852 times.
251852 else if(ispitfall(x+16,y+8))
8574 {
8575 clk3^=1;
8576 }
8577
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 251847 times.
251852 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8578 {
8579 5 clk3^=1;
8580 5 }
8581
2/2
✓ Branch 0 taken 251835 times.
✓ Branch 1 taken 12 times.
251847 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8582 {
8583 12 clk3^=1;
8584 12 }
8585 }
8586
8587 499211 --c;
8588
8589
4/4
✓ Branch 0 taken 153199 times.
✓ Branch 1 taken 346012 times.
✓ Branch 2 taken 324230 times.
✓ Branch 3 taken 174981 times.
499211 if(c<0 && step<zslongToFix(dstep*100))
8590 {
8591 174981 step+=zslongToFix(dmisc3*100);
8592 174981 }
8593
8594 499211 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8595
8596
2/2
✓ Branch 0 taken 498483 times.
✓ Branch 1 taken 728 times.
499211 if(x<=16-nb) clk3=right;
8597
8598
2/2
✓ Branch 0 taken 498214 times.
✓ Branch 1 taken 997 times.
499211 if(x>=world_w-32+nb) clk3=left;
8599
8600 499211 x += (clk3==left) ? -1 : 1;
8601
8602
4/4
✓ Branch 0 taken 29298 times.
✓ Branch 1 taken 469913 times.
✓ Branch 2 taken 10189 times.
✓ Branch 3 taken 459724 times.
499211 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8603 {
8604
4/4
✓ Branch 0 taken 1625 times.
✓ Branch 1 taken 17484 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 189 times.
39487 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8605 {
8606 189 step=0-step;
8607 189 y--;
8608 189 }
8609
2/2
✓ Branch 0 taken 5861 times.
✓ Branch 1 taken 13059 times.
18920 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8610 {
8611 13059 clk=misc=0;
8612 13059 } //land and jump again
8613 else
8614 {
8615 5861 misc=1;
8616 5861 clk2=0;
8617 }
8618 19109 }
8619
8620 478833 break;
8621 } // switch
8622 1271706 }
8623
8624
4/4
✓ Branch 0 taken 352454 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 236998 times.
✓ Branch 3 taken 115456 times.
1412248 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8625 {
8626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115456 times.
115456 if (moveflags & move_use_fake_z)
8627 {
8628 int32_t tempy = floor_y;
8629 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8630 floor_y = y;
8631 y=tempy-fakez;
8632 old_y = y;
8633 }
8634 else
8635 {
8636 115456 int32_t tempy = floor_y;
8637
6/6
✓ Branch 0 taken 58103 times.
✓ Branch 1 taken 57353 times.
✓ Branch 2 taken 109249 times.
✓ Branch 3 taken 6207 times.
✓ Branch 4 taken 53394 times.
✓ Branch 5 taken 55855 times.
115456 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8638 115456 floor_y = y;
8639 115456 y=tempy-z;
8640 115456 old_y = y;
8641 }
8642 115456 }
8643
8644
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1398684 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1412248 if(stunclk && (clk&31)==1)
8645 10637 clk=0;
8646
8647 1412248 return enemy::animate(index);
8648 1439215 }
8649
8650 1004450 bool eTektite::can_drawshadow() const
8651 {
8652
5/6
✓ Branch 0 taken 633102 times.
✓ Branch 1 taken 371348 times.
✓ Branch 2 taken 633102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26121 times.
✓ Branch 5 taken 606981 times.
1004450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8653 26121 return false;
8654
8655 978329 return enemy::can_drawshadow();
8656 1004450 }
8657 821032 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8658 {
8659
2/2
✓ Branch 0 taken 637614 times.
✓ Branch 1 taken 183418 times.
821032 if(!can_drawshadow())
8660 637614 return;
8661
8662 183418 int32_t tempy=yofs;
8663 183418 int32_t fdiv = frate/4;
8664
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8665
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8666 183418 efrate:((clk>=(frate>>1))?1:0);
8667 183418 flip = 0;
8668 183418 shadowtile = wpnsbuf[spr_shadow].tile;
8669
8670
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 if(get_qr(qr_NEWENEMYTILES))
8671 {
8672
2/2
✓ Branch 0 taken 114485 times.
✓ Branch 1 taken 68933 times.
183418 if(misc==0)
8673 {
8674 68933 shadowtile+=f2;
8675 68933 }
8676
2/2
✓ Branch 0 taken 50403 times.
✓ Branch 1 taken 64082 times.
114485 else if(misc!=1)
8677 64082 shadowtile+=2;
8678 183418 }
8679 else
8680 {
8681 if(misc==0)
8682 {
8683 shadowtile += f2 ? 1 : 0;
8684 }
8685 else if(misc!=1)
8686 {
8687 ++shadowtile;
8688 }
8689 }
8690
8691 183418 yofs+=8;
8692
8693
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 183418 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
183418 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8694 {
8695 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8696 }
8697 183418 enemy::drawshadow(dest,translucent);
8698 183418 yofs=tempy;
8699 821032 }
8700
8701 2084918 void eTektite::draw(BITMAP *dest)
8702 {
8703 2084918 update_enemy_frame();
8704 2084918 enemy::draw(dest);
8705 2084918 }
8706
8707 736 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8708 736 {
8709
2/4
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
736 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8710 736 superman=1;
8711 736 dir=8;
8712 736 hxofs=1000;
8713 736 mainguy=false;
8714 736 count_enemy=false;
8715
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 736 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
736 if (SIZEflags != 0) init_size_flags();;
8716 736 }
8717
8718 280632 bool eItemFairy::animate(int32_t index)
8719 {
8720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280632 times.
280632 if(switch_hooked) return enemy::animate(index);
8721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280632 times.
280632 if(dying)
8722 return Dead(index);
8723
8724 //if(clk>32)
8725 280632 misc=1;
8726 280632 bool w=watch;
8727 280632 watch=false;
8728 280632 variable_walk_8(misc?3:0,0,8,spw_floater);
8729 280632 watch=w;
8730
8731
2/2
✓ Branch 0 taken 1521 times.
✓ Branch 1 taken 279111 times.
280632 if(clk==0)
8732 {
8733 1521 removearmos(x,y);
8734 1521 }
8735
8736 280632 return enemy::animate(index);
8737 280632 }
8738
8739 563612 void eItemFairy::draw(BITMAP *dest)
8740 {
8741 //these are here to bypass compiler warnings about unused arguments
8742 563612 dest=dest;
8743 563612 }
8744
8745 1833 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8746 1833 {
8747 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8748
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
✓ Branch 2 taken 1833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1833 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1833 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1833 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1833 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1833 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1833 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1833 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1833 times.
✗ Branch 19 not taken.
1833 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8749 1833 dir=8;
8750 1833 movestatus=1;
8751 1833 clk=0;
8752
1/2
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
1833 step=0;
8753 //nets+720;
8754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1833 if (SIZEflags != 0) init_size_flags();;
8755 1833 }
8756
8757 522341 bool ePeahat::animate(int32_t index)
8758 {
8759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 522341 times.
522341 if(switch_hooked) return enemy::animate(index);
8760
2/4
✓ Branch 0 taken 522341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 522341 times.
522341 if(fallclk||drownclk) return enemy::animate(index);
8761
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 522263 times.
522341 if(slide())
8762 {
8763 78 update_current_screen();
8764 78 return false;
8765 }
8766
8767
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 521233 times.
522263 if(dying)
8768 1030 return Dead(index);
8769
8770
2/2
✓ Branch 0 taken 3095 times.
✓ Branch 1 taken 518138 times.
521233 if(clk==0)
8771 {
8772 3095 removearmos(x,y);
8773 3095 }
8774
8775
4/4
✓ Branch 0 taken 518115 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 254234 times.
✓ Branch 3 taken 263881 times.
521233 if(stunclk==0 && clk>96)
8776 263881 misc=1;
8777
8778
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 518831 times.
521233 if(!watch)
8779
2/2
✓ Branch 0 taken 172185 times.
✓ Branch 1 taken 346646 times.
518831 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8780
8781
3/4
✓ Branch 0 taken 101744 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101744 times.
521233 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8782 {
8783
1/2
✓ Branch 0 taken 101744 times.
✗ Branch 1 not taken.
101744 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8784 101744 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8785 101744 }
8786
8787
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 518831 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
521233 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8788 1634 superman=0;
8789 else
8790
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 509788 times.
519599 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8791 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8792
2/2
✓ Branch 0 taken 266663 times.
✓ Branch 1 taken 254570 times.
521233 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8793 {
8794
2/2
✓ Branch 0 taken 263548 times.
✓ Branch 1 taken 3115 times.
266663 if ( stunclk ) --stunclk;
8795 266663 }
8796 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8797 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8798
8799
8800
2/2
✓ Branch 0 taken 520993 times.
✓ Branch 1 taken 240 times.
521233 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8801
8802 521233 return enemy::animate(index);
8803 522341 }
8804
8805 336394 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8806 {
8807 336394 flip = 0;
8808
2/2
✓ Branch 0 taken 252623 times.
✓ Branch 1 taken 83771 times.
336394 if(!can_drawshadow())
8809 252623 return;
8810 83771 int32_t tempy=yofs;
8811 83771 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8812
8813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83771 times.
83771 if(!get_qr(qr_ENEMIESZAXIS))
8814 {
8815 yofs+=8;
8816 yofs+=int32_t(step/zslongToFix(dstep*10));
8817 }
8818 83771 enemy::drawshadow(dest,translucent);
8819 83771 yofs=tempy;
8820 336394 }
8821
8822 1149824 void ePeahat::draw(BITMAP *dest)
8823 {
8824 1149824 update_enemy_frame();
8825 1149824 enemy::draw(dest);
8826 1149824 }
8827
8828 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8829 {
8830 4136 int32_t wpnId = w->id;
8831 4136 int32_t enemyHitWeapon = w->parentitem;
8832
8833
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8834 return 0;
8835
8836
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8837 // fire boomerang, for nailing peahats
8838
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8839 3343 return 0;
8840
8841 // Time for a kludge...
8842 793 int32_t s = superman;
8843 793 superman = 0;
8844 793 int32_t ret = enemy::takehit(w,realweap);
8845 793 superman = s;
8846
8847 // Anyway...
8848
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8849 {
8850 192 clk2=0;
8851 192 movestatus=0;
8852 192 misc=0;
8853 192 clk=0;
8854 192 step=0;
8855 192 }
8856
8857 793 return ret;
8858 4136 }
8859
8860 // auomatically kill off enemy (for rooms with ringleaders)
8861 void ePeahat::kickbucket()
8862 {
8863 hp=-1000; // don't call death_sfx()
8864 }
8865
8866 4434 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8867 4434 {
8868 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8869
2/2
✓ Branch 0 taken 2235 times.
✓ Branch 1 taken 2199 times.
4434 if(dmisc1==0)
8870 {
8871 2199 misc=-1; //Line of Sight leevers
8872 2199 clk-=16;
8873 2199 }
8874 4434 clk3 = 0;
8875 //nets+1460;
8876 4434 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8877 4434 submerged = false;
8878
1/4
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4434 if (SIZEflags != 0) init_size_flags();;
8879 4434 }
8880
8881 2260 bool eLeever::isSubmerged() const
8882 {
8883 2260 return misc <= 0;
8884 }
8885
8886 1147511 bool eLeever::animate(int32_t index)
8887 {
8888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1147511 times.
1147511 if(switch_hooked) return enemy::animate(index);
8889
3/4
✓ Branch 0 taken 1146801 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1146801 times.
1147511 if(fallclk||drownclk)
8890 {
8891 710 return enemy::animate(index);
8892 }
8893
2/2
✓ Branch 0 taken 33572 times.
✓ Branch 1 taken 1113229 times.
1146801 if(dying)
8894 33572 return Dead(index);
8895
8896
2/2
✓ Branch 0 taken 1061638 times.
✓ Branch 1 taken 51591 times.
1113229 if(clk==0)
8897 {
8898 51591 removearmos(x,y);
8899 51591 }
8900
8901
4/4
✓ Branch 0 taken 925465 times.
✓ Branch 1 taken 187764 times.
✓ Branch 2 taken 7201 times.
✓ Branch 3 taken 918264 times.
1113229 if(clk>=0 && !slide())
8902 {
8903
2/2
✓ Branch 0 taken 347437 times.
✓ Branch 1 taken 570827 times.
918264 switch(dmisc1)
8904 {
8905 case 0: //line of sight
8906 case 2:
8907
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126285 times.
✓ Branch 2 taken 50473 times.
✓ Branch 3 taken 36580 times.
✓ Branch 4 taken 16242 times.
✓ Branch 5 taken 106113 times.
✓ Branch 6 taken 4536 times.
✓ Branch 7 taken 7208 times.
347437 switch(misc) //is this leever active
8908 {
8909 case -1: //submerged
8910 {
8911
4/6
✓ Branch 0 taken 8208 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 8208 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8208 times.
126285 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8912
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 115986 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
126285 if((dmisc1==2)&&(zc_oldrand()&255))
8913 {
8914 10261 break;
8915 }
8916
8917 116024 int32_t active=0;
8918
8919
2/2
✓ Branch 0 taken 793931 times.
✓ Branch 1 taken 116024 times.
909955 for(int32_t i=0; i<guys.Count(); i++)
8920 {
8921
4/4
✓ Branch 0 taken 634947 times.
✓ Branch 1 taken 158984 times.
✓ Branch 2 taken 405682 times.
✓ Branch 3 taken 229265 times.
793931 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8922 {
8923 229265 ++active;
8924 229265 }
8925 793931 }
8926
8927
2/2
✓ Branch 0 taken 114100 times.
✓ Branch 1 taken 1924 times.
116024 if(active<((dmisc1==2)?1:2))
8928 {
8929 1924 misc=0; //activate this one
8930 1924 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8931 1924 }
8932 }
8933 116024 break;
8934
8935 case 0:
8936 {
8937
8938
4/6
✓ Branch 0 taken 13284 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 13284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13284 times.
50473 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8939 {
8940 misc=1;
8941 clk2=0;
8942 }
8943
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 50415 times.
50473 else if (clk3<=0)
8944 {
8945 58 misc = -1;
8946 58 break;
8947 }
8948 50415 int32_t s=0;
8949
8950
2/2
✓ Branch 0 taken 279841 times.
✓ Branch 1 taken 50415 times.
330256 for(int32_t i=0; i<guys.Count(); i++)
8951 {
8952
4/4
✓ Branch 0 taken 167298 times.
✓ Branch 1 taken 112543 times.
✓ Branch 2 taken 159136 times.
✓ Branch 3 taken 8162 times.
279841 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8953 {
8954 8162 ++s;
8955 8162 }
8956 279841 }
8957
8958
2/2
✓ Branch 0 taken 8162 times.
✓ Branch 1 taken 42253 times.
50415 if(s>0)
8959 {
8960 8162 break;
8961 }
8962
8963 42253 int32_t d2=zc_oldrand()&1;
8964
8965
2/2
✓ Branch 0 taken 14692 times.
✓ Branch 1 taken 27561 times.
42253 if(HeroDir()>=left)
8966 {
8967 27561 d2+=2;
8968 27561 }
8969
8970
4/4
✓ Branch 0 taken 40761 times.
✓ Branch 1 taken 1492 times.
✓ Branch 2 taken 685 times.
✓ Branch 3 taken 40076 times.
42253 if(canplace(d2) || canplace(d2^1))
8971 {
8972 2177 misc=1;
8973 2177 clk2=0;
8974 2177 clk=0;
8975 2177 }
8976 }
8977 42253 break;
8978
8979 case 1:
8980
8981
7/8
✓ Branch 0 taken 34448 times.
✓ Branch 1 taken 2132 times.
✓ Branch 2 taken 4647 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 4647 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4646 times.
36580 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8982
8983 36580 break;
8984
8985 case 2:
8986
8987
7/8
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 1970 times.
✓ Branch 2 taken 1910 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1910 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1909 times.
16242 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8988
8989 16242 break;
8990
8991 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8992 case 3:
8993
8994
5/6
✓ Branch 0 taken 102524 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 102524 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 99797 times.
106113 if(stunclk || frozenclock || watch) break;
8995
8996
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 99654 times.
99797 if(scored) dir^=1;
8997
8998
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 99273 times.
99797 if(!canmove(dir,false)) misc=4;
8999 99273 else move(zslongToFix(dstep*100));
9000
9001 99797 break;
9002
9003 case 4:
9004
4/6
✓ Branch 0 taken 781 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 781 times.
4536 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9005
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 487 times.
4536 if(--clk2<=16)
9006 {
9007 487 misc=5;
9008 487 clk=8;
9009 487 }
9010
9011 4536 break;
9012
9013 case 5:
9014
5/6
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1310 times.
7208 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9015
2/2
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 428 times.
7208 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9016
9017 7208 break;
9018 } // switch(misc)
9019
9020 347437 break;
9021
9022 default: //random
9023 // step=d->misc3/100.0;
9024
9025 570827 step=zslongToFix(dmisc3*100);
9026
5/6
✓ Branch 0 taken 97013 times.
✓ Branch 1 taken 473814 times.
✓ Branch 2 taken 97013 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✓ Branch 5 taken 96943 times.
570827 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9027
3/6
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
70 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9028 {
9029
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (clk2 < 48) clk2+=2;
9030
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (clk2 >= 300) clk2-=2;
9031 70 }
9032
9033
2/2
✓ Branch 0 taken 75127 times.
✓ Branch 1 taken 495700 times.
570827 if(clk2<32) misc=1;
9034
2/2
✓ Branch 0 taken 37104 times.
✓ Branch 1 taken 458596 times.
495700 else if(clk2<48) misc=2;
9035
2/2
✓ Branch 0 taken 348113 times.
✓ Branch 1 taken 110483 times.
458596 else if(clk2<300)
9036 {
9037 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9038 {
9039 fix_coords();
9040 }*/
9041 348113 misc=3;
9042 348113 step = zslongToFix(dstep*100);
9043 348113 }
9044
2/2
✓ Branch 0 taken 10512 times.
✓ Branch 1 taken 99971 times.
110483 else if(clk2<316) misc=2;
9045
2/2
✓ Branch 0 taken 51567 times.
✓ Branch 1 taken 48404 times.
99971 else if(clk2<412) misc=1;
9046
2/2
✓ Branch 0 taken 48074 times.
✓ Branch 1 taken 330 times.
48404 else if(clk2<540)
9047 {
9048 48074 misc=0;
9049 48074 step=0;
9050 48074 }
9051 330 else clk2=0;
9052
9053
2/2
✓ Branch 0 taken 568557 times.
✓ Branch 1 taken 2270 times.
570827 if(clk2==48) clk=0;
9054
9055 // variable_walk(d->rate, d->homing, 0);
9056 570827 variable_walk(rate, homing, 0);
9057 570827 } // switch(dmisc1)
9058 918264 }
9059
9060 1113229 hxofs=(misc>=2)?0:1000;
9061 1113229 return enemy::animate(index);
9062 1147511 }
9063
9064 83014 bool eLeever::canplace(int32_t d2)
9065 {
9066 83014 int32_t nx=HeroX();
9067 83014 int32_t ny=HeroY();
9068
9069
2/2
✓ Branch 0 taken 28840 times.
✓ Branch 1 taken 54174 times.
83014 if(d2<left) ny=TRUNCATE_TILE(ny);
9070 54174 else nx=TRUNCATE_TILE(nx);
9071
9072
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14347 times.
✓ Branch 2 taken 14493 times.
✓ Branch 3 taken 27073 times.
✓ Branch 4 taken 27101 times.
83014 switch(d2)
9073 {
9074 case up:
9075
2/2
✓ Branch 0 taken 14317 times.
✓ Branch 1 taken 30 times.
14347 ny-=((dmisc1==0||dmisc1==2)?32:48);
9076 14347 break;
9077
9078 case down:
9079
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14459 times.
14493 ny+=((dmisc1==0||dmisc1==2)?32:48);
9080
9081
4/4
✓ Branch 0 taken 10212 times.
✓ Branch 1 taken 4281 times.
✓ Branch 2 taken 10201 times.
✓ Branch 3 taken 11 times.
14493 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9082
9083 14493 break;
9084
9085 case left:
9086
2/2
✓ Branch 0 taken 26420 times.
✓ Branch 1 taken 653 times.
27073 nx-=((dmisc1==0||dmisc1==2)?32:48);
9087 27073 break;
9088
9089 case right:
9090
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 26455 times.
27101 nx+=((dmisc1==0||dmisc1==2)?32:48);
9091
9092
4/4
✓ Branch 0 taken 19994 times.
✓ Branch 1 taken 7107 times.
✓ Branch 2 taken 19392 times.
✓ Branch 3 taken 602 times.
27101 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9093
9094 27101 break;
9095 }
9096
9097
4/4
✓ Branch 0 taken 21099 times.
✓ Branch 1 taken 61915 times.
✓ Branch 2 taken 9435 times.
✓ Branch 3 taken 11664 times.
83014 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9098 71350 return false;
9099
9100
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 10773 times.
11664 if(d2>=left)
9101
4/4
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 5694 times.
✓ Branch 2 taken 9487 times.
✓ Branch 3 taken 1286 times.
10773 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9102 9487 return false;
9103
9104 2177 x=nx;
9105 2177 y=ny;
9106 2177 dir=d2^1;
9107 2177 return true;
9108 83014 }
9109
9110 1160500 void eLeever::draw(BITMAP *dest)
9111 {
9112 // cs=d->cset;
9113 1160500 cs=dcset;
9114 1160500 update_enemy_frame();
9115
3/4
✓ Branch 0 taken 1159790 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1159790 times.
1160500 if(!fallclk&&!drownclk)
9116 {
9117
2/2
✓ Branch 0 taken 743153 times.
✓ Branch 1 taken 416637 times.
1159790 switch(misc)
9118 {
9119 case -1:
9120 case 0:
9121 416637 return;
9122 }
9123 743153 }
9124
9125 743863 enemy::draw(dest);
9126 1160500 }
9127
9128 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9129 998 {
9130 998 hashero=false;
9131 //nets+1000;
9132
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9133 998 }
9134
9135 504762 bool eWallM::animate(int32_t index)
9136 {
9137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9138
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9139 {
9140 return enemy::animate(index);
9141 }
9142
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9143 9856 return Dead(index);
9144
9145
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9146 {
9147 30976 removearmos(x,y);
9148 30976 }
9149
9150 494906 hxofs=1000;
9151
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9152 {
9153
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9154 {
9155 211789 int32_t wall=hero_on_wall();
9156 211789 int32_t wallm_cnt=0;
9157
9158
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9159
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->type==eeWALLM)
9160 {
9161 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9162
9163
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9164 {
9165 13366 ++wallm_cnt;
9166 13366 }
9167 1013091 }
9168
9169
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9170 {
9171 841 --wall;
9172 841 misc=1; //emerging from the wall?
9173 841 clk2=0;
9174 841 clk3=wall^1;
9175 841 wallm_load_clk=frame;
9176
9177
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9178 {
9179
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9180 91 dir=right;
9181 else
9182 423 dir=left;
9183 514 }
9184 else
9185 {
9186
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9187 66 dir=down;
9188 else
9189 261 dir=up;
9190 }
9191
9192
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9193 {
9194 case up:
9195 231 y=0;
9196 231 break;
9197
9198 case down:
9199 283 y=160;
9200 283 break;
9201
9202 case left:
9203 223 x=0;
9204 223 break;
9205
9206 case right:
9207 104 x=240;
9208 104 break;
9209 }
9210
9211
9212
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9213 {
9214 case up:
9215 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9216 261 flip=wall&1;
9217 261 break;
9218
9219 case down:
9220 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9221 66 flip=((wall&1)^1)+2;
9222 66 break;
9223
9224 case left:
9225 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9226 423 flip=(wall==up?2:0)+1;
9227 423 break;
9228
9229 case right:
9230 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9231 91 flip=(wall==up?2:0);
9232 91 break;
9233 }
9234
9235 841 }
9236 211789 }
9237 377174 }
9238 else
9239 117732 wallm_crawl();
9240
9241 494906 return enemy::animate(index);
9242 504762 }
9243
9244 117732 void eWallM::wallm_crawl()
9245 {
9246 117732 bool w=watch;
9247 117732 hxofs=0;
9248
9249
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9250 {
9251 810 return;
9252 }
9253
9254 // if(dying || watch || (!hashero && stunclk))
9255
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9256 {
9257 14546 return;
9258 }
9259
9260 102376 watch=false;
9261 102376 ++clk2;
9262 // Misc1: slightly different movement
9263 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9264
9265 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9267
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9268 {
9269 4491 --clk2;
9270 4491 }
9271
9272
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9273 {
9274 case 1:
9275 case 2:
9276 52852 zc_swap(dir,clk3);
9277 52852 move(step);
9278 52852 zc_swap(dir,clk3);
9279 52852 break;
9280
9281 case 3:
9282 case 4:
9283 case 5:
9284
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9285 {
9286 4491 watch=w;
9287 4491 return;
9288 }
9289
9290 34905 move(step);
9291 34905 break;
9292
9293 case 6:
9294 case 7:
9295 9984 zc_swap(dir,clk3);
9296 9984 dir^=1;
9297 9984 move(step);
9298 9984 dir^=1;
9299 9984 zc_swap(dir,clk3);
9300 9984 break;
9301
9302 default:
9303 144 misc=0;
9304 144 break;
9305 }
9306
9307 97885 watch=w;
9308 117732 }
9309
9310 9 void eWallM::grabhero()
9311 {
9312 9 hashero=true;
9313 9 superman=1;
9314 9 }
9315
9316 507147 void eWallM::draw(BITMAP *dest)
9317 {
9318 507147 dummy_bool[1]=hashero;
9319 507147 update_enemy_frame();
9320
9321
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9322 {
9323 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9324 129181 }
9325
9326 // enemy::draw(dest);
9327 // tile = clk&8 ? 128:129;
9328 507147 }
9329
9330 bool eWallM::isSubmerged() const
9331 {
9332 return ( !misc );
9333 }
9334
9335 1680 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9336 1680 {
9337
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 ox=x; //original x
9338
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 oy=y; //original y
9339
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 206 times.
1680 if(get_qr(qr_TRAPPOSFIX))
9340 {
9341
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 206 times.
✗ Branch 3 not taken.
206 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9342 206 }
9343
9344 1680 mainguy=false;
9345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9346 //nets+420;
9347 1680 dummy_int[1]=0;
9348
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1680 if (SIZEflags != 0) init_size_flags();;
9349 1680 }
9350
9351 1054519 bool eTrap::animate(int32_t index)
9352 {
9353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1054519 times.
1054519 if(switch_hooked) return enemy::animate(index);
9354
2/4
✓ Branch 0 taken 1054519 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1054519 times.
1054519 if(fallclk||drownclk) return enemy::animate(index);
9355
2/2
✓ Branch 0 taken 1032785 times.
✓ Branch 1 taken 21734 times.
1054519 if(clk<0)
9356 21734 return enemy::animate(index);
9357
9358
2/2
✓ Branch 0 taken 967448 times.
✓ Branch 1 taken 65337 times.
1032785 if(clk==0)
9359 {
9360 65337 removearmos(x,y);
9361 65337 }
9362
9363
2/2
✓ Branch 0 taken 321964 times.
✓ Branch 1 taken 710821 times.
1032785 if(misc==0) // waiting
9364 {
9365 710821 ox = x;
9366 710821 oy = y;
9367 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9368 710821 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9369
9370
4/4
✓ Branch 0 taken 247420 times.
✓ Branch 1 taken 463401 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 110045 times.
710821 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9371 {
9372 110045 dir=down;
9373 110045 }
9374
4/4
✓ Branch 0 taken 398123 times.
✓ Branch 1 taken 202653 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 260748 times.
600776 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9375 {
9376 260748 dir=right;
9377 260748 }
9378
4/4
✓ Branch 0 taken 216363 times.
✓ Branch 1 taken 123665 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 78988 times.
340028 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9379 {
9380 78988 dir=up;
9381 78988 }
9382 else
9383 {
9384 261040 dir=left;
9385 }
9386
9387 710821 int32_t d2=lined_up(15,true);
9388
9389
4/4
✓ Branch 0 taken 272171 times.
✓ Branch 1 taken 438650 times.
✓ Branch 2 taken 1110486 times.
✓ Branch 3 taken 399665 times.
1107466 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9390
2/2
✓ Branch 0 taken 234727 times.
✓ Branch 1 taken 164938 times.
399665 ((d2>down) && (dmisc1==2)) ||
9391
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 32767 times.
164938 ((d2>right) && (!dmisc1)) ||
9392
2/2
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 176809 times.
219836 ((d2<l_up) && (dmisc1==4)) ||
9393
3/4
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 219836 times.
✓ Branch 2 taken 396645 times.
✗ Branch 3 not taken.
176809 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9394
3/4
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 176809 times.
✓ Branch 2 taken 396645 times.
✗ Branch 3 not taken.
219836 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9395 {
9396 2535148 d2=-1;
9397 2535148 }
9398
9399
4/4
✓ Branch 0 taken 20966 times.
✓ Branch 1 taken 470019 times.
✓ Branch 2 taken 18829 times.
✓ Branch 3 taken 2137 times.
490985 if(d2!=-1 && trapmove(d2))
9400 {
9401 2137 dir=d2;
9402 2137 misc=1;
9403 2137 clk2=(dir==down)?3:0;
9404 2137 }
9405 490985 }
9406
9407
2/2
✓ Branch 0 taken 722607 times.
✓ Branch 1 taken 90342 times.
812949 if(misc==1) // charging
9408 {
9409 90342 clk2=(clk2+1)&3;
9410 90342 step=(clk2==3)?1:2;
9411
9412
4/4
✓ Branch 0 taken 89516 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 88411 times.
90342 if(!trapmove(dir) || clip())
9413 {
9414 1931 misc=2;
9415
9416
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(dir<l_up)
9417 {
9418 1931 dir=dir^1;
9419 1931 }
9420 else
9421 {
9422 dir=dir^3;
9423 }
9424 1931 }
9425 else
9426 {
9427 88411 sprite::move(step);
9428 }
9429 90342 }
9430
9431
2/2
✓ Branch 0 taken 577259 times.
✓ Branch 1 taken 235690 times.
812949 if(misc==2) // retreating
9432 {
9433 235690 step=(++clk2&1)?1:0;
9434
9435
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39305 times.
✓ Branch 2 taken 81283 times.
✓ Branch 3 taken 29536 times.
✓ Branch 4 taken 85566 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
235690 switch(dir)
9436 {
9437 case up:
9438
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 39030 times.
39305 if(int32_t(y)<=oy) goto trap_rest;
9439 39030 else sprite::move(step);
9440
9441 39030 break;
9442
9443 case left:
9444
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 80889 times.
81283 if(int32_t(x)<=ox) goto trap_rest;
9445 80889 else sprite::move(step);
9446
9447 80889 break;
9448
9449 case down:
9450
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 29310 times.
29536 if(int32_t(y)>=oy) goto trap_rest;
9451 29310 else sprite::move(step);
9452
9453 29310 break;
9454
9455 case right:
9456
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 85127 times.
85566 if(int32_t(x)>=ox) goto trap_rest;
9457 85127 else sprite::move(step);
9458
9459 85127 break;
9460
9461 case l_up:
9462 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9463 else sprite::move(step);
9464
9465 break;
9466
9467 case r_up:
9468 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9469 else sprite::move(step);
9470
9471 break;
9472
9473 case l_down:
9474 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9475 else sprite::move(step);
9476
9477 break;
9478
9479 case r_down:
9480 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9481 else sprite::move(step);
9482
9483 break;
9484 trap_rest:
9485 {
9486 1334 x=ox;
9487 1334 y=oy;
9488 1334 misc=0;
9489 }
9490 1334 }
9491 235690 }
9492
9493 812949 return enemy::animate(index);
9494 834683 }
9495
9496 111308 bool eTrap::trapmove(int32_t ndir)
9497 {
9498
2/2
✓ Branch 0 taken 81544 times.
✓ Branch 1 taken 29764 times.
111308 if(get_qr(qr_MEANTRAPS))
9499 {
9500 81544 mapscr* scr = get_scr(screen_spawned);
9501
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 80204 times.
81544 if(scr->flags2&fFLOATTRAPS)
9502 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9503
9504 80204 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9505 }
9506
9507
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9508 4730 return false;
9509
9510
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9511 return false;
9512
9513
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9514 return false;
9515
9516
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9517 return false;
9518
9519
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9520 4722 return false;
9521
9522
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9523 713 return false;
9524
9525
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9526 return false;
9527
9528
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9529 return false;
9530
9531
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9532 return false;
9533
9534
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9535 return false;
9536
9537 19599 return true;
9538 111308 }
9539
9540 89516 bool eTrap::clip()
9541 {
9542
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 46494 times.
89516 if(get_qr(qr_MEANPLACEDTRAPS))
9543 {
9544
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5954 times.
✓ Branch 2 taken 8764 times.
✓ Branch 3 taken 16437 times.
✓ Branch 4 taken 15339 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
46494 switch(dir)
9545 {
9546 case up:
9547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5954 times.
5954 if(y<=0) return true;
9548
9549 5954 break;
9550
9551 case down:
9552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8764 times.
8764 if(y>=world_h-16) return true;
9553
9554 8764 break;
9555
9556 case left:
9557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16437 times.
16437 if(x<=0) return true;
9558
9559 16437 break;
9560
9561 case right:
9562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15339 times.
15339 if(x>=world_w-16) return true;
9563
9564 15339 break;
9565
9566 case l_up:
9567 if(y<=0||x<=0) return true;
9568
9569 break;
9570
9571 case l_down:
9572 if(y>=world_h-16||x<=0) return true;
9573
9574 break;
9575
9576 case r_up:
9577 if(y<=0||x>=world_w-16) return true;
9578
9579 break;
9580
9581 case r_down:
9582 if(y>=world_h-16||x>=world_w-16) return true;
9583
9584 break;
9585 }
9586
9587 46494 return false;
9588 }
9589 else
9590 {
9591
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9592 {
9593 case up:
9594
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9595
9596 4695 break;
9597
9598 case down:
9599
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9600
9601 5253 break;
9602
9603 case left:
9604
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9605
9606 16376 break;
9607
9608 case right:
9609
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9610
9611 15593 break;
9612
9613 case l_up:
9614 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9615
9616 break;
9617
9618 case l_down:
9619 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9620
9621 break;
9622
9623 case r_up:
9624 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9625
9626 break;
9627
9628 case r_down:
9629 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9630
9631 break;
9632 }
9633
9634 41917 return false;
9635 }
9636 89516 }
9637
9638 1073433 void eTrap::draw(BITMAP *dest)
9639 {
9640 1073433 update_enemy_frame();
9641 1073433 enemy::draw(dest);
9642 1073433 }
9643
9644 5755 int32_t eTrap::takehit(weapon*,weapon*)
9645 {
9646 5755 return 0;
9647 }
9648
9649 893 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9650 893 {
9651 893 lasthit=-1;
9652 893 lasthitclk=0;
9653 893 mainguy=false;
9654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9655
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 step=2;
9656
3/6
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9657 {
9658
2/4
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
436 dir=(x<=112)?right:left;
9659 436 }
9660 else
9661 {
9662
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 dir=(y<=72)?down:up;
9663 }
9664
9665
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 133 times.
893 if(get_qr(qr_TRAPPOSFIX))
9666 {
9667
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9668 133 }
9669
9670 //nets+((id==eTRAP_LR)?540:520);
9671 893 dummy_int[1]=0;
9672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if (SIZEflags != 0) init_size_flags();;
9673 893 }
9674
9675 370041 bool eTrap2::animate(int32_t index)
9676 {
9677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 370041 times.
370041 if(switch_hooked) return enemy::animate(index);
9678
2/4
✓ Branch 0 taken 370041 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 370041 times.
370041 if(fallclk||drownclk) return enemy::animate(index);
9679
2/2
✓ Branch 0 taken 358893 times.
✓ Branch 1 taken 11148 times.
370041 if(clk<0)
9680 11148 return enemy::animate(index);
9681
9682
2/2
✓ Branch 0 taken 22873 times.
✓ Branch 1 taken 336020 times.
358893 if(clk==0)
9683 {
9684 22873 removearmos(x,y);
9685 22873 }
9686
9687
2/2
✓ Branch 0 taken 234567 times.
✓ Branch 1 taken 124326 times.
358893 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9688 {
9689
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9690 {
9691 11074 --lasthitclk;
9692 11074 }
9693 else
9694 {
9695 113252 lasthit=-1;
9696 }
9697
9698 124326 bool hitenemy=false;
9699
9700
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9701 {
9702
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9703 {
9704
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9705 {
9706 3669 lasthit=j;
9707 3669 lasthitclk=10;
9708 3669 hitenemy=true;
9709 3669 guys.spr(j)->lasthit=index;
9710 3669 guys.spr(j)->lasthitclk=10;
9711 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9712 3669 }
9713 730351 }
9714 864860 }
9715
9716
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9717 {
9718
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9719 {
9720 3155 lasthit=-1;
9721 3155 lasthitclk=0;
9722 3155 }
9723
9724
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9725 362 sfx(WAV_ZN1TAP,pan(x));
9726
9727 5986 dir=dir^1;
9728 5986 }
9729
9730 124326 sprite::move(step);
9731 124326 }
9732 else
9733 {
9734
3/4
✓ Branch 0 taken 226871 times.
✓ Branch 1 taken 7696 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 226871 times.
234567 if(!trapmove(dir) || clip())
9735 {
9736
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 2298 times.
7696 if(get_qr(qr_MORESOUNDS))
9737 2298 sfx(WAV_ZN1TAP,pan(x));
9738
9739 7696 dir=dir^1;
9740 7696 }
9741
9742 234567 sprite::move(step);
9743 }
9744
9745 358893 return enemy::animate(index);
9746 370041 }
9747
9748 364879 bool eTrap2::trapmove(int32_t ndir)
9749 {
9750 364879 mapscr* scr = get_scr(screen_spawned);
9751
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 363001 times.
364879 if(scr->flags2&fFLOATTRAPS)
9752 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9753
9754 363001 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9755 364879 }
9756
9757 350873 bool eTrap2::clip()
9758 {
9759
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 94187 times.
✓ Branch 2 taken 94862 times.
✓ Branch 3 taken 80685 times.
✓ Branch 4 taken 81139 times.
350873 switch(dir)
9760 {
9761 case up:
9762
1/2
✓ Branch 0 taken 94187 times.
✗ Branch 1 not taken.
94187 if(y<=0) return true;
9763
9764 94187 break;
9765
9766 case down:
9767
1/2
✓ Branch 0 taken 94862 times.
✗ Branch 1 not taken.
94862 if(y>=world_h-16) return true;
9768
9769 94862 break;
9770
9771 case left:
9772
1/2
✓ Branch 0 taken 80685 times.
✗ Branch 1 not taken.
80685 if(x<=0) return true;
9773
9774 80685 break;
9775
9776 case right:
9777
1/2
✓ Branch 0 taken 81139 times.
✗ Branch 1 not taken.
81139 if(x>=world_w-16) return true;
9778
9779 81139 break;
9780 }
9781
9782 350873 return false;
9783 350873 }
9784
9785 375587 void eTrap2::draw(BITMAP *dest)
9786 {
9787 375587 update_enemy_frame();
9788 375587 enemy::draw(dest);
9789 375587 }
9790
9791 3281 int32_t eTrap2::takehit(weapon*,weapon*)
9792 {
9793 3281 return 0;
9794 }
9795
9796 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9797 354 {
9798 //do not show "enemy appering" anim -DD
9799 354 clk=0;
9800 354 mainguy=false;
9801 354 clk2=-14;
9802 //Enemy Editor Size Tab
9803
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9804 //nets+1640;
9805 354 }
9806
9807 354 void eRock::init_size_flags()
9808 {
9809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9810 354 else hxofs = -2;
9811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9812 354 else hyofs = -2;
9813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9814 354 else hit_width = 20;
9815
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9816 354 else hit_height = 20;
9817
9818
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9821
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9822
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9823 {
9824 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9825 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9826 }
9827
9828
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9829 354 }
9830
9831 121997 bool eRock::animate(int32_t index)
9832 {
9833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9834
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9836 return Dead(index);
9837
9838
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9839 {
9840 8376 removearmos(x,y);
9841 8376 }
9842
9843
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9844 {
9845 697 x=zc_oldrand()&0xF0;
9846 697 y=0;
9847 697 clk3=0;
9848 697 clk2=zc_oldrand()&15;
9849 697 }
9850
9851
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9852 {
9853
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9854 {
9855 3430 dir=zc_oldrand()&1;
9856
9857
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9858
9859
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9860 3430 }
9861
9862
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9863 {
9864 95993 x += dir ? 1 : -1; //right, left
9865 95993 dummy_int[1]=dir;
9866
9867
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9868 {
9869 6852 y-=2; //up
9870 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9871 6852 }
9872
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9873 {
9874 10208 y--; //up
9875 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9876 10208 }
9877
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9878 {
9879 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9880 10135 }
9881
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9882 {
9883 10058 y++; //down
9884 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9885 10058 }
9886 else
9887 {
9888 58740 y+=2; //down
9889 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9890 }
9891
9892 95993 ++clk3;
9893 95993 }
9894
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9895 2761 clk3=0; // next bounce
9896 else
9897 423 clk2 = -(zc_oldrand()&63); // back to top
9898 99177 }
9899
9900 121997 return enemy::animate(index);
9901 121997 }
9902
9903 51441 bool eRock::can_drawshadow() const
9904 {
9905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51441 times.
51441 if(shadow_overpit())
9906 return false;
9907
9908 51441 return clk2>=0;
9909 51441 }
9910 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9911 {
9912
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(!can_drawshadow())
9913 7191 return;
9914 44250 int32_t tempy=yofs;
9915 44250 flip = 0;
9916 44250 int32_t fdiv = frate/4;
9917
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9918
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9919 44250 efrate:((clk>=(frate>>1))?1:0);
9920 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9921
9922 44250 yofs+=8;
9923
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9924 44250 sprite::drawshadow(dest, translucent);
9925 44250 yofs=tempy;
9926 51441 }
9927
9928 122078 void eRock::draw(BITMAP *dest)
9929 {
9930
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9931 {
9932 105043 int32_t tempdir=dir;
9933 105043 dir=dummy_int[2];
9934 105043 update_enemy_frame();
9935 105043 enemy::draw(dest);
9936 105043 dir=tempdir;
9937 105043 }
9938 122078 }
9939
9940 1014 int32_t eRock::takehit(weapon*,weapon*)
9941 {
9942 1014 return 0;
9943 }
9944
9945 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9946 30 {
9947 30 clk=0;
9948 30 mainguy=false;
9949 30 clk2=-14;
9950
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9951 //nets+1680;
9952 30 }
9953
9954 4440 bool eBoulder::animate(int32_t index)
9955 {
9956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9957
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9959 return Dead(index);
9960
9961
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9962 {
9963 290 removearmos(x,y);
9964 290 }
9965
9966 zfix *vert;
9967
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9968
9969
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9970 {
9971 32 x=zc_oldrand()&0xF0;
9972 32 y=-32;
9973 32 clk3=0;
9974 32 clk2=zc_oldrand()&15;
9975 32 }
9976
9977
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9978 {
9979
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9980 {
9981 131 dir=zc_oldrand()&1;
9982
9983
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9984
9985
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9986 131 }
9987
9988
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9989 {
9990 3487 x += dir ? 1 : -1; //right, left
9991 3487 dummy_int[1]=dir;
9992
9993
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9994 {
9995 261 y-=2; //up
9996 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9997 261 }
9998
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9999 {
10000 382 y--; //up
10001 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10002 382 }
10003
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10004 {
10005 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10006 376 }
10007
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10008 {
10009 367 y++; //down
10010 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10011 367 }
10012 else
10013 {
10014 2101 y+=2; //down
10015 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10016 }
10017
10018 3487 ++clk3;
10019 3487 }
10020
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10021 101 clk3=0; // next bounce
10022 else
10023 10 clk2 = -(zc_oldrand()&63); // back to top
10024 3598 }
10025
10026 4440 return enemy::animate(index);
10027 4440 }
10028
10029 4440 bool eBoulder::can_drawshadow() const
10030 {
10031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(shadow_overpit())
10032 return false;
10033
10034 4440 return clk2>=0;
10035 4440 }
10036 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10037 {
10038
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(!can_drawshadow())
10039 572 return;
10040 3868 int32_t tempy=yofs;
10041 3868 flip = 0;
10042 3868 int32_t f2=((clk<<2)/frate)<<1;
10043 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10044
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10045
10046 3868 yofs+=8;
10047 3868 xofs-=8;
10048 3868 sprite::drawshadow(dest, translucent);
10049 3868 xofs+=16;
10050 3868 ++shadowtile;
10051 3868 sprite::drawshadow(dest, translucent);
10052 3868 yofs+=16;
10053 3868 shadowtile+=20;
10054 3868 sprite::drawshadow(dest, translucent);
10055 3868 xofs-=16;
10056 3868 --shadowtile;
10057 3868 sprite::drawshadow(dest, translucent);
10058 3868 xofs+=8;
10059 3868 yofs=tempy;
10060 4440 }
10061
10062 4440 void eBoulder::draw(BITMAP *dest)
10063 {
10064
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10065 {
10066 3868 int32_t tempdir=dir;
10067 3868 dir=dummy_int[2];
10068 3868 update_enemy_frame();
10069 3868 dir=tempdir;
10070 3868 xofs-=8;
10071 3868 yofs-=8;
10072 3868 drawblock(dest,15);
10073 3868 xofs+=8;
10074 3868 yofs+=8;
10075 // enemy::draw(dest);
10076 3868 }
10077 4440 }
10078
10079 30 void eBoulder::init_size_flags()
10080 {
10081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10082 30 else hxofs = -10;
10083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10084 30 else hyofs = -10;
10085
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10086 30 else hit_width = 36;
10087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10088 30 else hit_height = 36;
10089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10090 30 else hzsz = 16; //can't be jumped
10091
10092
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10093
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10095
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10096
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10097 {
10098 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10099 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10100 }
10101
10102
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10103 30 }
10104
10105 int32_t eBoulder::takehit(weapon*,weapon*)
10106 {
10107 return 0;
10108 }
10109
10110 4433 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10111
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 3898 times.
4433 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10112 4433 {
10113 /* fixing
10114 hp=1;
10115 */
10116 4433 mainguy=false;
10117
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4426 times.
4433 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10118 4433 hclk=clk; // the "no fire" range
10119 4433 clk=0;
10120 4433 clk3=96;
10121 4433 timer=0;
10122
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4415 times.
4433 if(o_tile==0)
10123 {
10124 4415 superman=1;
10125 4415 hxofs=1000;
10126 4415 }
10127
1/4
✓ Branch 0 taken 4433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4433 if (SIZEflags != 0) init_size_flags();;
10128 4433 }
10129
10130 2505003 bool eProjectile::animate(int32_t index)
10131 {
10132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2505003 times.
2505003 if(switch_hooked) return enemy::animate(index);
10133
2/4
✓ Branch 0 taken 2505003 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2505003 times.
2505003 if(fallclk||drownclk) return enemy::animate(index);
10134
2/2
✓ Branch 0 taken 2492673 times.
✓ Branch 1 taken 12330 times.
2505003 if(clk==0)
10135 {
10136 12330 removearmos(x,y);
10137 12330 }
10138
10139 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10140 2505003 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10141
10142
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669395 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2505003 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10143 {
10144 403631 dir=down;
10145 403631 }
10146
4/4
✓ Branch 0 taken 1349154 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 917177 times.
2101372 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10147 {
10148 917177 dir=right;
10149 917177 }
10150
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10151 {
10152 358900 dir=up;
10153 358900 }
10154 else
10155 {
10156 825295 dir=left;
10157 }
10158
10159
3/4
✓ Branch 0 taken 2505003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306384 times.
✓ Branch 3 taken 1198619 times.
2505003 if(!stunclk && ++clk3>80)
10160 {
10161
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197573 times.
1198619 if(dmisc1==9) // Breath type
10162 {
10163
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10164 {
10165 563 unsigned r=zc_oldrand();
10166
10167
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10168 {
10169 6 timer=zc_oldrand()%50+50;
10170 6 }
10171 563 }
10172
10173
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10174 {
10175
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10176 {
10177 119 FireBreath(false);
10178 119 }
10179
10180
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10181 {
10182 6 clk3=0;
10183 6 }
10184 489 }
10185 1046 }
10186
10187 else // Not breath type
10188 {
10189 1197573 unsigned r=zc_oldrand();
10190
10191
4/4
✓ Branch 0 taken 18811 times.
✓ Branch 1 taken 1178762 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17545 times.
1197573 if(!(r&63) && !HeroInRange(minRange))
10192 {
10193 17545 FireWeapon();
10194
10195
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2505 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17797 if(get_qr(qr_BROKENSTATUES)==0 &&
10196
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10197 {
10198
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10199 {
10200 909 x-=4;
10201 909 FireWeapon();
10202 909 x+=4;
10203 909 }
10204 14854 }
10205
10206 17545 clk3=0;
10207 17545 }
10208 }
10209 1198619 }
10210
10211 2505003 return enemy::animate(index);
10212 2505003 }
10213
10214 2520592 void eProjectile::draw(BITMAP *dest)
10215 {
10216 2520592 update_enemy_frame();
10217 2520592 enemy::draw(dest);
10218 2520592 }
10219
10220 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10221 533 {
10222 533 hxofs=1000;
10223 533 }
10224
10225 249811 void eTrigger::draw(BITMAP *dest)
10226 {
10227 249811 update_enemy_frame();
10228 249811 enemy::draw(dest);
10229 249811 }
10230
10231 void eTrigger::death_sfx()
10232 {
10233 //silent death
10234 }
10235
10236 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10237 5 {
10238 5 o_tile+=wpnsbuf[iwNPCs].tile;
10239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10240 5 SIZEflags = d->SIZEflags;
10241
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10242 5 }
10243
10244 75 bool eNPC::animate(int32_t index)
10245 {
10246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10247
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10248 70 return Dead(index);
10249
10250
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10251 {
10252 removearmos(x,y);
10253 }
10254
10255
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10256 {
10257 case 0:
10258 {
10259 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10260 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10261
10262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10263 {
10264 dir=down;
10265 }
10266
10267
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10268 {
10269 5 dir=right;
10270 5 }
10271 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10272 {
10273 dir=up;
10274 }
10275 else
10276 {
10277 dir=left;
10278 }
10279 }
10280 5 break;
10281
10282 case 1:
10283 halting_walk(rate, homing, 0, hrate, 48);
10284
10285 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10286 {
10287 newdir(rate, homing, 0);
10288 clk2=48;
10289 ++misc;
10290 }
10291
10292 if(clk2==0)
10293 misc=0;
10294
10295 break;
10296 }
10297
10298 5 return enemy::animate(index);
10299 75 }
10300
10301 75 void eNPC::draw(BITMAP *dest)
10302 {
10303 75 update_enemy_frame();
10304 75 enemy::draw(dest);
10305 75 }
10306
10307 int32_t eNPC::takehit(weapon*,weapon*)
10308 {
10309 return 0;
10310 }
10311
10312 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10313 94 {
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10315 {
10316 94 o_tile=clk;
10317 94 cs=id>>12;
10318 94 }
10319
10320 94 id=id&0xFFF;
10321 94 clk=0;
10322
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10323 94 mainguy=false;
10324 94 SIZEflags = d->SIZEflags;
10325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10326 94 }
10327
10328 81 void eSpinTile::facehero()
10329 {
10330
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10331 {
10332
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10333 1 dir = up;
10334 else
10335 dir = down;
10336 1 }
10337 else
10338 {
10339 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10340 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10341
10342
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10343 {
10344 12 dir=l_down;
10345 12 }
10346
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10347 {
10348 1 dir=down;
10349 1 }
10350
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10351 {
10352 12 dir=r_down;
10353 12 }
10354
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10355 {
10356 6 dir=right;
10357 6 }
10358
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10359 {
10360 17 dir=r_up;
10361 17 }
10362
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10363 {
10364 8 dir=up;
10365 8 }
10366
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10367 {
10368 6 dir=l_up;
10369 6 }
10370 else
10371 {
10372 18 dir=left;
10373 }
10374 }
10375 81 }
10376
10377
10378 15539 bool eSpinTile::animate(int32_t index)
10379 {
10380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10381
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10382
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10383 {
10384 1152 return Dead(index);
10385 }
10386
10387
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10388 {
10389 1241 removearmos(x,y);
10390 1241 }
10391
10392 14387 ++misc;
10393
10394
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10395 {
10396 81 facehero();
10397 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10398 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10399 81 angular=true;
10400 81 angle=ddir;
10401 81 step=zslongToFix(dstep*100);
10402 81 }
10403
10404
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10405 52 kickbucket();
10406
10407 14387 sprite::move(step);
10408 14387 return enemy::animate(index);
10409 15539 }
10410
10411 15457 void eSpinTile::draw(BITMAP *dest)
10412 {
10413 15457 update_enemy_frame();
10414 15457 y-=(misc>>4);
10415 15457 yofs+=2;
10416 15457 enemy::draw(dest);
10417 15457 yofs-=2;
10418 15457 y+=(misc>>4);
10419 15457 }
10420
10421 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10422 {
10423 15457 flip = 0;
10424
1/2
✓ Branch 0 taken 15457 times.
✗ Branch 1 not taken.
15457 if(!can_drawshadow())
10425 15457 return;
10426 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10427 yofs+=4;
10428 enemy::drawshadow(dest, translucent);
10429 yofs-=4;
10430 15457 }
10431
10432 2874 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10433 2874 {
10434 //these are here to bypass compiler warnings about unused arguments
10435 2874 Clk=Clk;
10436 2874 mainguy=false;
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2874 times.
2874 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10438
1/4
✓ Branch 0 taken 2874 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2874 if (SIZEflags != 0) init_size_flags();;
10439 2874 }
10440
10441 643945 void eZora::facehero()
10442 {
10443
2/2
✓ Branch 0 taken 10802 times.
✓ Branch 1 taken 633143 times.
643945 if(Hero.x-x==0)
10444 {
10445 10802 dir=(Hero.y+8<y)?up:down;
10446 10802 }
10447 else
10448 {
10449 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10450 633143 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10451
10452
4/4
✓ Branch 0 taken 128467 times.
✓ Branch 1 taken 504676 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 79916 times.
633143 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10453 {
10454 79916 dir=l_down;
10455 79916 }
10456
4/4
✓ Branch 0 taken 94203 times.
✓ Branch 1 taken 459024 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 45652 times.
553227 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10457 {
10458 45652 dir=down;
10459 45652 }
10460
4/4
✓ Branch 0 taken 123472 times.
✓ Branch 1 taken 384103 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 74921 times.
507575 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10461 {
10462 74921 dir=r_down;
10463 74921 }
10464
4/4
✓ Branch 0 taken 166271 times.
✓ Branch 1 taken 266383 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 117720 times.
432654 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10465 {
10466 117720 dir=right;
10467 117720 }
10468
4/4
✓ Branch 0 taken 130916 times.
✓ Branch 1 taken 184018 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 82365 times.
314934 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10469 {
10470 82365 dir=r_up;
10471 82365 }
10472
4/4
✓ Branch 0 taken 91723 times.
✓ Branch 1 taken 140846 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 43172 times.
232569 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10473 {
10474 43172 dir=up;
10475 43172 }
10476
4/4
✓ Branch 0 taken 126673 times.
✓ Branch 1 taken 62724 times.
✓ Branch 2 taken 78122 times.
✓ Branch 3 taken 48551 times.
189397 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10477 {
10478 78122 dir=l_up;
10479 78122 }
10480 else
10481 {
10482 111275 dir=left;
10483 }
10484 }
10485 643945 }
10486
10487 872768 bool eZora::animate(int32_t index)
10488 {
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 872768 times.
872768 if(switch_hooked) return enemy::animate(index);
10490
2/2
✓ Branch 0 taken 2954 times.
✓ Branch 1 taken 869814 times.
872768 if(dying)
10491 2954 return Dead(index);
10492
10493
2/2
✓ Branch 0 taken 863948 times.
✓ Branch 1 taken 5866 times.
869814 if(clk==0)
10494 {
10495 5866 removearmos(x,y);
10496 5866 }
10497
10498
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 869779 times.
869814 if(watch)
10499 {
10500 35 clock_zoras.push_back({screen_spawned, id});
10501 35 return true;
10502 }
10503
10504
2/2
✓ Branch 0 taken 225834 times.
✓ Branch 1 taken 643945 times.
869779 if(get_qr(qr_NEWENEMYTILES))
10505 {
10506 643945 facehero();
10507 643945 }
10508
10509
6/6
✓ Branch 0 taken 5341 times.
✓ Branch 1 taken 5092 times.
✓ Branch 2 taken 4266 times.
✓ Branch 3 taken 845474 times.
✓ Branch 4 taken 6586 times.
✓ Branch 5 taken 3020 times.
869779 switch(clk)
10510 {
10511 case 0: // reposition him
10512 {
10513 6586 int32_t t=0;
10514 6586 int32_t pos2=zc_oldrand()%160 + 16;
10515 6586 bool placed=false;
10516
10517
4/4
✓ Branch 0 taken 6514 times.
✓ Branch 1 taken 40421 times.
✓ Branch 2 taken 28041 times.
✓ Branch 3 taken 5866 times.
46935 while(!placed && t<160)
10518 {
10519 28041 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10520 95711 auto [sx, sy] = COMBOXY_REGION(rpos);
10521 28041 mapscr* s = get_scr(screen_spawned);
10522
10523 84123 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10524
6/6
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 21321 times.
✓ Branch 2 taken 6709 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 403 times.
✓ Branch 5 taken 5794 times.
34238 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10525
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6677 times.
6709 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10526
3/4
✓ Branch 0 taken 6677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6197 times.
✓ Branch 3 taken 6154 times.
6720 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10527 {
10528 5794 x=sx;
10529 5794 y=sy;
10530
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5454 times.
5794 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10531 5794 hxofs=1000; // avoid hit detection
10532 5794 stunclk=0;
10533 5794 placed=true;
10534 5794 }
10535
10536 40349 pos2+=19;
10537
10538
2/2
✓ Branch 0 taken 35573 times.
✓ Branch 1 taken 4776 times.
40349 if(pos2>=176)
10539 4776 pos2-=160;
10540
10541 40349 ++t;
10542 }
10543
10544
3/4
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5794 times.
5866 if(!placed || whistleclk>=88) // can't place him, he's gone
10545 72 return true;
10546
10547 }
10548 5794 break;
10549
10550 case 35:
10551
2/2
✓ Branch 0 taken 3980 times.
✓ Branch 1 taken 1361 times.
5341 if(!get_qr(qr_NEWENEMYTILES))
10552 {
10553 1361 dir=(Hero.y+8<y)?up:down;
10554 1361 }
10555
10556 5341 hxofs=0;
10557 5341 break;
10558
10559 case 35+19:
10560 5092 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10561 5092 sfx(wpnsfx(wpn),pan(x));
10562 5092 break;
10563
10564 case 35+66:
10565 4266 hxofs=1000;
10566 4266 break;
10567
10568 case 198:
10569 3020 clk=-1;
10570 3020 break;
10571 }
10572
10573 868987 return enemy::animate(index);
10574 872048 }
10575
10576 884024 void eZora::draw(BITMAP *dest)
10577 {
10578
2/2
✓ Branch 0 taken 20355 times.
✓ Branch 1 taken 863669 times.
884024 if (isSubmerged())
10579 20355 return;
10580
10581 863669 update_enemy_frame();
10582 863669 enemy::draw(dest);
10583 884024 }
10584
10585 884256 bool eZora::isSubmerged() const
10586 {
10587 884256 return clk < 3;
10588 }
10589
10590
3/6
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52553 times.
✗ Branch 5 not taken.
105106 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10591 52553 {
10592 52553 multishot= timer = fired = dashing = 0;
10593 52553 hashero = false;
10594 52553 dummy_bool[0]=false;
10595
4/8
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52553 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52553 times.
✗ Branch 7 not taken.
52553 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10596
5/6
✓ Branch 0 taken 1004 times.
✓ Branch 1 taken 51549 times.
✓ Branch 2 taken 1004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 520 times.
✓ Branch 5 taken 484 times.
52553 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10597 {
10598
2/4
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 520 times.
✗ Branch 3 not taken.
520 step=zslongToFix(dmisc10*100);
10599
10600
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 502 times.
520 if(anim==aARMOS4) o_tile+=20;
10601 520 }
10602
10603
3/4
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1004 times.
✓ Branch 3 taken 51549 times.
52553 if(flags & guy_fade_flicker)
10604 {
10605 1004 clk=0;
10606 1004 superman = 1;
10607 1004 fading=fade_flicker;
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1004 times.
1004 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10609 1004 dir=down;
10610
10611
4/6
✓ Branch 0 taken 1004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 561 times.
1004 if(!canmove(down,(zfix)8,spw_none,false))
10612
3/6
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 443 times.
✗ Branch 5 not taken.
443 clk3=int32_t(13.0/step);
10613 1004 }
10614
3/4
✓ Branch 0 taken 51549 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51416 times.
✓ Branch 3 taken 133 times.
51549 else if(flags & guy_fade_instant)
10615 {
10616 133 clk=0;
10617 133 }
10618
10619
1/2
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
52553 shadowdistance = 0;
10620 52553 clk4 = clk5 = 0;
10621 //nets+2380;
10622
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 52551 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
52553 if (SIZEflags != 0) init_size_flags();;
10623 52553 }
10624
10625 16383593 bool eStalfos::animate(int32_t index)
10626 {
10627
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 16383337 times.
16383593 if(switch_hooked) return enemy::animate(index);
10628
4/4
✓ Branch 0 taken 16382414 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 16381070 times.
16383337 if(fallclk||drownclk)
10629 {
10630 2267 return enemy::animate(index);
10631 }
10632
2/2
✓ Branch 0 taken 369776 times.
✓ Branch 1 taken 16011294 times.
16381070 if(dying)
10633 {
10634
2/2
✓ Branch 0 taken 369725 times.
✓ Branch 1 taken 51 times.
369776 if(hashero)
10635 {
10636 51 Hero.setEaten(0);
10637 51 hashero=false;
10638 51 }
10639
10640
10/14
✓ Branch 0 taken 38171 times.
✓ Branch 1 taken 331605 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 34486 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
369776 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10641 {
10642 187 hp=-1000;
10643
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10644 187 Ewpns.add(ew);
10645 187 ew->fakez = fakez;
10646
10647
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10648 {
10649 187 ew->step=0;
10650 187 ew->id=wpn;
10651 187 ew->misc=50;
10652 187 ew->clk=48;
10653 187 }
10654
10655 187 fired=true;
10656 187 }
10657
6/6
✓ Branch 0 taken 163945 times.
✓ Branch 1 taken 205644 times.
✓ Branch 2 taken 137553 times.
✓ Branch 3 taken 26392 times.
✓ Branch 4 taken 137535 times.
✓ Branch 5 taken 18 times.
369589 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10658 {
10659
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10660 {
10661 1 int32_t wpn2 = wpn+dmisc3;
10662
10663
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10664 {
10665 wpn2=wpn;
10666 }
10667
10668 1 dummy_bool[0]=true;
10669 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10670 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10671 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10672 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10673 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10674 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10675 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10676 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10677 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10678 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10679 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10680 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10681 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10682 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10683 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10684 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10685 1 sfx(wpnsfx(wpn2),pan(x));
10686 1 }
10687 18 }
10688
10689 369776 KillWeapon();
10690 369776 return Dead(index);
10691 }
10692 //vire split
10693 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10694 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10695
13/14
✓ Branch 0 taken 22021 times.
✓ Branch 1 taken 15989273 times.
✓ Branch 2 taken 22021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 390 times.
✓ Branch 5 taken 21631 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14818208 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
16011294 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10696 {
10697 1716 stop_bgsfx(index);
10698 1716 int32_t kids = guys.Count();
10699 1716 int32_t id2=dmisc3;
10700
2/2
✓ Branch 0 taken 3385 times.
✓ Branch 1 taken 1716 times.
5101 for(int32_t i=0; i < dmisc4; i++)
10701 {
10702
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2113 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3385 times.
3385 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].type==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10703 3385 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10704 3385 }
10705
10706
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1716 if (itemguy && guys.Count()) // Hand down the carried item
10707 {
10708 1 int guycarryingitem = guys.Count()-1;
10709 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10710 1 itemguy = false;
10711 1 }
10712
10713
2/2
✓ Branch 0 taken 1699 times.
✓ Branch 1 taken 17 times.
1716 if(hashero)
10714 {
10715 17 Hero.setEaten(0);
10716 17 hashero=false;
10717 17 }
10718
10719
4/4
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 362 times.
1716 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10720 362 sfx(deadsfx,pan(x));
10721
10722 1716 return true;
10723 }
10724
10725
2/2
✓ Branch 0 taken 71283 times.
✓ Branch 1 taken 15938295 times.
16009578 if(fading)
10726 {
10727
2/2
✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 70053 times.
71283 if(++clk4 > 60)
10728 {
10729 1230 clk4=0;
10730 1230 superman=0;
10731 1230 fading=0;
10732
10733
4/6
✓ Branch 0 taken 969 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 969 times.
1230 if(flags&guy_armos && z==0 && fakez == 0)
10734 {
10735 //if a custom size (not 16px by 16px)
10736
10737 //if a custom size (not 16px by 16px)
10738
3/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 178 times.
✗ Branch 3 not taken.
969 if (activated_handle && !activated_handle->is_rpos())
10739 removearmos(x,y);
10740 else
10741 {
10742
4/8
✓ Branch 0 taken 969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 969 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 969 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 969 times.
969 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10743 {
10744 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10745 for(int32_t dx = 0; dx < tysz; dx ++)
10746 {
10747 for(int32_t dy = 0; dy < tysz; dy++)
10748 {
10749 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10750 did_armos = false;
10751 }
10752 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10753 did_armos = false;
10754 }
10755 for(int32_t dy = 0; dy < tysz; dy ++)
10756 {
10757 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10758 did_armos = false;
10759 }
10760 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10761 }
10762 969 else removearmos(x,y);
10763 }
10764
10765 969 }
10766
10767 1230 clk2=0;
10768
10769 1230 newdir();
10770 1230 }
10771 70053 else return enemy::animate(index);
10772 1230 }
10773
6/8
✓ Branch 0 taken 148631 times.
✓ Branch 1 taken 15789664 times.
✓ Branch 2 taken 148631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139061 times.
✓ Branch 7 taken 9570 times.
15938295 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10774 9570 removearmos(x,y);
10775
10776
10777
2/2
✓ Branch 0 taken 7873 times.
✓ Branch 1 taken 15931652 times.
15939525 if(hashero)
10778 {
10779 7873 Hero.setX(x);
10780 7873 Hero.setY(y);
10781 7873 ++clk2;
10782
10783
4/4
✓ Branch 0 taken 6360 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6784 times.
✓ Branch 3 taken 1089 times.
7873 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10784 {
10785
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1058 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
1089 switch(dmisc7)
10786 {
10787 case e7tEATITEMS:
10788 {
10789
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10790 {
10791
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10792 22 game->set_item(i, false);
10793 5632 }
10794
10795 22 break;
10796 }
10797
10798 case e7tEATMAGIC:
10799 9 game->change_dmagic(-1*game->get_magicdrainrate());
10800 9 break;
10801
10802 case e7tEATRUPEES:
10803 game->change_drupy(-1);
10804 break;
10805 }
10806
10807 1089 clk2=0;
10808 1089 }
10809
10810
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 7312 times.
7873 if((clk&0x18)==8) // stop its animation on the middle frame
10811 7312 --clk;
10812 7873 }
10813
4/4
✓ Branch 0 taken 1056599 times.
✓ Branch 1 taken 14875053 times.
✓ Branch 2 taken 620077 times.
✓ Branch 3 taken 436522 times.
15931652 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10814 {
10815 // Movement engine
10816
6/6
✓ Branch 0 taken 844908 times.
✓ Branch 1 taken 14650222 times.
✓ Branch 2 taken 3399 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14646656 times.
✓ Branch 5 taken 59 times.
15495130 if(clk>=0) switch(id>>12)
10817 {
10818 case 0: // Normal movement
10819
10820 /*
10821 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10822 {
10823 // Overloading clk4 (Tribble clock) here...
10824 step=17/100.0;
10825 if(clk4<32) misc=1;
10826 else if(clk4<48) misc=2;
10827 else if(clk4<300) { misc=3; step = dstep/100.0; }
10828 else if(clk4<316) misc=2;
10829 else if(clk4<412) misc=1;
10830 else if(clk4<540) { misc=0; step=0; }
10831 else clk4=0;
10832 if(clk4==48) clk=0;
10833 hxofs=(misc>=2)?0:1000;
10834 if (dmisc9==e9tLEEVER)
10835 variable_walk(rate, homing, 0);
10836 else
10837 variable_walk_8(rate, homing, 4, 0);
10838 break;
10839 }
10840 */
10841
4/4
✓ Branch 0 taken 14267622 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13850546 times.
14646656 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10842 {
10843 796110 vire_hop();
10844 796110 break;
10845 }
10846
2/2
✓ Branch 0 taken 1061272 times.
✓ Branch 1 taken 12789274 times.
13850546 else if(dmisc9==e9tROPE) //Rope charge
10847 {
10848
9/10
✓ Branch 0 taken 1043850 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 153470 times.
✓ Branch 3 taken 890380 times.
✓ Branch 4 taken 141385 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 140560 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 140560 times.
1061272 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10849 {
10850
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 131484 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
140560 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10851 {
10852
10853
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10854 {
10855 14 hp=-1000;
10856
10857
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10858 {
10859
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10860 14 Ewpns.add(ew);
10861 14 ew->fakez = fakez;
10862
10863
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10864 {
10865 14 ew->step=0;
10866 14 ew->id=wpn+dmisc3;
10867 14 ew->misc=50;
10868 14 ew->clk=48;
10869 14 }
10870
10871 14 fired=true;
10872 14 }
10873 else
10874 {
10875 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10876 Ewpns.add(ew);
10877 ew->fakez = fakez;
10878
10879 if(wpn==ewSBomb || wpn==ewBomb)
10880 {
10881 ew->step=0;
10882 ew->id=wpn;
10883 ew->misc=50;
10884 ew->clk=48;
10885 }
10886
10887 fired=true;
10888 }
10889 14 }
10890
10891 else
10892 {
10893 33 hp=-1000;
10894
10895 int32_t wpn2;
10896
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10897 33 wpn2=wpn;
10898 else
10899 wpn2=wpn;
10900
10901
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10902 33 Ewpns.add(ew);
10903 33 ew->fakez = fakez;
10904
10905
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10906 {
10907 33 ew->step=0;
10908 33 ew->id=wpn2;
10909 33 ew->misc=50;
10910 33 ew->clk=48;
10911 33 }
10912
10913 33 fired=true;
10914 }
10915 47 }
10916 140560 }
10917
10918 1061272 charge_attack();
10919 1061272 break;
10920 }
10921 /*
10922 * Boomerang-throwers have a halt count of 1
10923 * Zols have a halt count of (zc_oldrand()&7)<<4
10924 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10925 * Everything else has 48
10926 */
10927 else
10928 {
10929
2/2
✓ Branch 0 taken 572383 times.
✓ Branch 1 taken 12216891 times.
12789274 if(wpn==ewBrang) // Goriya
10930 {
10931 572383 halting_walk(rate,homing,0,hrate, 1);
10932 572383 }
10933
4/4
✓ Branch 0 taken 12067291 times.
✓ Branch 1 taken 149600 times.
✓ Branch 2 taken 4783350 times.
✓ Branch 3 taken 7283941 times.
12216891 else if(dmisc9==e9tNORMAL && wpn==0)
10934 {
10935
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6565968 times.
7283941 if(dmisc2==e2tSPLITHIT) // Zol
10936 {
10937 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10938 717973 }
10939
4/4
✓ Branch 0 taken 1773827 times.
✓ Branch 1 taken 4792141 times.
✓ Branch 2 taken 1557936 times.
✓ Branch 3 taken 215891 times.
6565968 else if(frate<=8 && starting_hp==1) // Gel
10940 {
10941 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10942 215891 }
10943 else // Other
10944 {
10945 6350077 halting_walk(rate,homing,0,hrate, 48);
10946 }
10947 7283941 }
10948 else // Other
10949 {
10950 4932950 halting_walk(rate,homing,0,hrate, 48);
10951 }
10952 }
10953
10954 //if not in midair, and Hero's swinging sword is nearby, jump.
10955 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10956 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10957 {
10958 facehero(false);
10959 sclk=16+((dir^1)<<8);
10960 fall=-FEATHERJUMP;
10961 sfx(WAV_ZN1JUMP,pan(x));
10962 }*/
10963 12789274 break;
10964
10965 // Following cases are for just after creation-by-splitting.
10966 case 1:
10967
2/2
✓ Branch 0 taken 2555 times.
✓ Branch 1 taken 844 times.
3399 if(misc==1)
10968 {
10969 844 dir=up;
10970 844 step=8;
10971 844 }
10972
10973
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 2588 times.
3399 if(misc<=2)
10974 {
10975 2588 move(step);
10976
10977
2/2
✓ Branch 0 taken 2049 times.
✓ Branch 1 taken 539 times.
2588 if(!canmove(dir,(zfix)0,0,false))
10978 539 dir=down;
10979 2588 }
10980
10981
2/2
✓ Branch 0 taken 2588 times.
✓ Branch 1 taken 811 times.
3399 if(misc==3)
10982 {
10983
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 517 times.
811 if(canmove(right,(zfix)16,0,false))
10984 517 x+=16;
10985 811 }
10986
10987 3399 ++misc;
10988 3399 break;
10989
10990 case 2:
10991
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10992 {
10993 15 dir=down;
10994 15 step=8;
10995 15 }
10996
10997
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10998 {
10999 45 move(step);
11000 /*
11001 if(!canmove(dir,(zfix)0,0,false))
11002 dir=up;
11003 */
11004 45 }
11005
11006
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11007 {
11008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11009 14 x-=16;
11010 14 }
11011
11012 59 ++misc;
11013 59 break;
11014
11015 default:
11016
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11017 {
11018 28 dir=(zc_oldrand()%4);
11019 28 step=8;
11020 28 }
11021
11022
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11023 {
11024 83 move(step);
11025
11026
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11027 2 dir=dir^1;
11028 83 }
11029
11030
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11031 {
11032
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11033 8 x+=(dir==left ? -16 : 16);
11034 25 }
11035
11036 108 ++misc;
11037 108 break;
11038 14650222 }
11039
11040
4/4
✓ Branch 0 taken 25806 times.
✓ Branch 1 taken 15469324 times.
✓ Branch 2 taken 24956 times.
✓ Branch 3 taken 850 times.
15495130 if(id>>12 && misc>=4) //recently spawned by a split enemy
11041 {
11042 850 id&=0xFFF;
11043 850 step = zslongToFix(dstep*100);
11044
11045
2/2
✓ Branch 0 taken 849 times.
✓ Branch 1 taken 1 times.
850 if(x<32) x=32;
11046
11047
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 24 times.
850 if(x>world_w-48) x=world_w-48;
11048
11049
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 26 times.
850 if(y<32) y=32;
11050
11051
2/2
✓ Branch 0 taken 843 times.
✓ Branch 1 taken 7 times.
850 if(y>world_h-48) y=world_h-48;
11052
11053 850 misc=3;
11054 850 }
11055 15495130 }
11056 else
11057 {
11058 //sfx(wpnsfx(wpn),pan(x));
11059
1/2
✓ Branch 0 taken 436522 times.
✗ Branch 1 not taken.
436522 if(clk2>2) clk2--;
11060 }
11061
11062 // Fire Zol
11063
8/8
✓ Branch 0 taken 6346424 times.
✓ Branch 1 taken 9593101 times.
✓ Branch 2 taken 174420 times.
✓ Branch 3 taken 6172004 times.
✓ Branch 4 taken 1375 times.
✓ Branch 5 taken 173045 times.
✓ Branch 6 taken 1334 times.
✓ Branch 7 taken 41 times.
15939525 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11064 {
11065 1334 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11066 1334 sfx(wpnsfx(wpn),pan(x));
11067
11068 1334 int32_t i=Ewpns.Count()-1;
11069 1334 weapon *ew = (weapon*)(Ewpns.spr(i));
11070
11071
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1334 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11072 {
11073 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11074 if ( ew->do_animation ) ew->tile+=ew->aframe;
11075 }
11076 1334 }
11077 // Goriya
11078
14/16
✓ Branch 0 taken 1056599 times.
✓ Branch 1 taken 14881592 times.
✓ Branch 2 taken 472320 times.
✓ Branch 3 taken 584279 times.
✓ Branch 4 taken 459560 times.
✓ Branch 5 taken 12760 times.
✓ Branch 6 taken 426583 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 426583 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 423842 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 423842 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 417426 times.
✓ Branch 15 taken 6416 times.
15938191 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11079 {
11080 6416 misc=index+100;
11081
7/14
✓ Branch 0 taken 6416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6416 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6416 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6416 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6416 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6416 times.
✗ Branch 13 not taken.
6416 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11082 6416 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11083
11084
2/2
✓ Branch 0 taken 6159 times.
✓ Branch 1 taken 257 times.
6416 if(dmisc1==2)
11085 {
11086 257 int32_t ndir=dir;
11087
11088
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11089 {
11090 6 ndir=(Hero.y+8<y)?up:down;
11091 6 }
11092 else //turn to face Hero
11093 {
11094 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11095 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11096
11097
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11098 {
11099 13 ndir=down;
11100 13 }
11101
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11102 {
11103 68 ndir=right;
11104 68 }
11105
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11106 {
11107 48 ndir=up;
11108 48 }
11109 else
11110 {
11111 122 ndir=left;
11112 }
11113 }
11114
11115 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11116
11117
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11118 {
11119 223 dir=ndir;
11120 223 }
11121 257 }
11122 6416 }
11123
15/16
✓ Branch 0 taken 15870915 times.
✓ Branch 1 taken 60860 times.
✓ Branch 2 taken 223166 times.
✓ Branch 3 taken 15708609 times.
✓ Branch 4 taken 196679 times.
✓ Branch 5 taken 26487 times.
✓ Branch 6 taken 171787 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 170382 times.
✓ Branch 9 taken 1405 times.
✓ Branch 10 taken 155282 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 155282 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 154338 times.
15931775 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11124
3/3
✓ Branch 0 taken 27446 times.
✓ Branch 1 taken 125986 times.
✓ Branch 2 taken 906 times.
154338 switch(dmisc1)
11125 {
11126 case e1tCONSTANT: //Deathnut
11127 {
11128 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11129
2/2
✓ Branch 0 taken 123398 times.
✓ Branch 1 taken 2588 times.
125986 if(clk5>64)
11130 {
11131 2588 clk5=0;
11132 2588 fired=false;
11133 2588 }
11134
11135 125986 clk5+=(zc_oldrand()&3);
11136
11137
4/4
✓ Branch 0 taken 76865 times.
✓ Branch 1 taken 49121 times.
✓ Branch 2 taken 25698 times.
✓ Branch 3 taken 51167 times.
125986 if((clk5>24)&&(clk5<52))
11138 {
11139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51167 times.
51167 if ( do_animation )tile+=20; //firing
11140
11141
4/4
✓ Branch 0 taken 28011 times.
✓ Branch 1 taken 23156 times.
✓ Branch 2 taken 25178 times.
✓ Branch 3 taken 2833 times.
51167 if(!fired&&(clk5>=38))
11142 {
11143
5/10
✓ Branch 0 taken 2833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2833 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2833 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2833 times.
✗ Branch 9 not taken.
2833 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11144 2833 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11145 2833 sfx(wpnsfx(wpn),pan(x));
11146 2833 fired=true;
11147 2833 }
11148 51167 }
11149
11150 125986 break;
11151 }
11152
11153 case e1tFIREOCTO: //Fire Octo
11154 906 timer=zc_oldrand()%50+50;
11155 906 break;
11156
11157 default:
11158 27446 FireWeapon();
11159 27446 break;
11160 154338 }
11161
11162 /* Fire again if:
11163 * - clk2 about to run out
11164 * - not already double-firing (dmisc1 is 1)
11165 * - not carrying Hero
11166 * - one in 0xF chance
11167 */
11168
8/10
✓ Branch 0 taken 530545 times.
✓ Branch 1 taken 15408980 times.
✓ Branch 2 taken 4567 times.
✓ Branch 3 taken 525978 times.
✓ Branch 4 taken 4567 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4567 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4277 times.
✓ Branch 9 taken 290 times.
15939525 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11169 {
11170 #if 1
11171 290 newdir(rate, homing, grumble);
11172 #else
11173 dir^=2;
11174 #endif
11175 290 clk2=28;
11176 290 ++multishot;
11177 290 }
11178
11179
2/2
✓ Branch 0 taken 3594397 times.
✓ Branch 1 taken 12345128 times.
15939525 if(clk2==0)
11180 {
11181 12345128 multishot = 0;
11182 12345128 }
11183
11184
2/2
✓ Branch 0 taken 15875215 times.
✓ Branch 1 taken 64310 times.
15939525 if(timer) //Fire Octo
11185 {
11186 64310 clk2=15; //this keeps the octo in place until he's done firing
11187
11188
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11189 {
11190 15752 FireBreath(false);
11191 15752 }
11192
11193 64310 --timer;
11194 64310 }
11195
11196
2/2
✓ Branch 0 taken 15690132 times.
✓ Branch 1 taken 249393 times.
15939525 if(dmisc2==e2tTRIBBLE)
11197 249393 ++clk4;
11198
11199
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15935045 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15938832 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15939525 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11200 {
11201 693 int32_t kids = guys.Count();
11202 693 int32_t id2=dmisc3;
11203
11204
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11205 {
11206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11207 {
11208
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11209 {
11210 int guycarryingitem = guys.Count()-1;
11211 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11212 itemguy = false;
11213 }
11214
11215 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11216 693 }
11217 693 }
11218
11219
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11220 {
11221 Hero.setEaten(0);
11222 hashero=false;
11223 }
11224
11225 693 stop_bgsfx(index);
11226 693 return true;
11227 }
11228
11229 15938832 return enemy::animate(index);
11230 16383593 }
11231
11232 16837213 void eStalfos::draw(BITMAP *dest)
11233 {
11234 16837213 update_enemy_frame();
11235
11236
8/8
✓ Branch 0 taken 16836290 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 16834946 times.
✓ Branch 3 taken 1344 times.
✓ Branch 4 taken 87435 times.
✓ Branch 5 taken 16747511 times.
✓ Branch 6 taken 76320 times.
✓ Branch 7 taken 11115 times.
16837213 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11237 {
11238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11239 11115 }
11240
11241 16837213 enemy::draw(dest);
11242 16837213 }
11243
11244 8111423 bool eStalfos::can_drawshadow() const
11245 {
11246 8111423 return enemy::can_drawshadow();
11247 }
11248 8111423 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11249 {
11250 8111423 int32_t tempy=yofs;
11251
11252
4/4
✓ Branch 0 taken 7896005 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7799804 times.
✓ Branch 3 taken 311619 times.
8111423 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11253 {
11254 311619 flip = 0;
11255 311619 int32_t fdiv = frate/4;
11256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11257
11258
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11259 311619 efrate:((clk>=(frate>>1))?1:0);
11260 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11261
11262
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11263 {
11264 311619 shadowtile+=f2;
11265 311619 }
11266 else
11267 {
11268 shadowtile+=f2?1:0;
11269 }
11270
11271 311619 yofs+=shadowdistance;
11272 311619 yofs+=8;
11273 311619 }
11274
4/4
✓ Branch 0 taken 7896005 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 8108388 times.
✓ Branch 3 taken 3035 times.
8111423 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11275 {
11276 3035 flip = 0;
11277 3035 int32_t fdiv = frate/4;
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11279
11280
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11281 3035 efrate:((clk>=(frate>>1))?1:0);
11282 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11283
11284
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11285 {
11286 3035 shadowtile+=f2;
11287 3035 }
11288 else
11289 {
11290 shadowtile+=f2?1:0;
11291 }
11292 3035 }
11293 8111423 enemy::drawshadow(dest, translucent);
11294 8111423 yofs=tempy;
11295 8111423 }
11296
11297 160669 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11298 {
11299 160669 int32_t wpnId = w->id;
11300 160669 int32_t wpnDir = w->dir;
11301
11302
4/4
✓ Branch 0 taken 1453 times.
✓ Branch 1 taken 159216 times.
✓ Branch 2 taken 631 times.
✓ Branch 3 taken 822 times.
160669 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11303
6/8
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 407 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 131 times.
631 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11304
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11305 {
11306 276 shield = false;
11307 276 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11308
11309
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 254 times.
276 if(get_qr(qr_BRKNSHLDTILES))
11310 254 o_tile=s_tile;
11311 276 }
11312
11313 160669 int32_t ret = enemy::takehit(w,realweap);
11314
11315
4/4
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 137144 times.
✓ Branch 2 taken 21774 times.
✓ Branch 3 taken 1751 times.
160669 if(sclk && dmisc2==e2tSPLITHIT)
11316 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11317
11318 160669 return ret;
11319 }
11320
11321 1061272 void eStalfos::charge_attack()
11322 {
11323
2/2
✓ Branch 0 taken 8516 times.
✓ Branch 1 taken 1052756 times.
1061272 if(slide())
11324 8516 return;
11325
11326
10/12
✓ Branch 0 taken 1052756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1050352 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 1020716 times.
✓ Branch 5 taken 29636 times.
✓ Branch 6 taken 999163 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 992627 times.
✓ Branch 9 taken 6536 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 992627 times.
1052756 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11327 60129 return;
11328
11329
2/2
✓ Branch 0 taken 40922 times.
✓ Branch 1 taken 951705 times.
992627 if(clk3<=0)
11330 {
11331 40922 fix_coords(true);
11332
11333
2/2
✓ Branch 0 taken 11132 times.
✓ Branch 1 taken 29790 times.
40922 if(!dashing)
11334 {
11335 29790 int32_t ldir = lined_up(7,false);
11336
11337
4/4
✓ Branch 0 taken 3397 times.
✓ Branch 1 taken 26393 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 2905 times.
29790 if(ldir!=-1 && canmove(ldir,false))
11338 {
11339 2905 dir=ldir;
11340 2905 dashing=true;
11341
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2905 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2905 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11342 2905 step=zslongToFix(dstep*100)+1;
11343 else
11344 step=zslongToFix(dmisc10*100);
11345 2905 }
11346 26885 else newdir(4,0,0);
11347 29790 }
11348
11349
2/2
✓ Branch 0 taken 39330 times.
✓ Branch 1 taken 1592 times.
40922 if(!canmove(dir,false))
11350 {
11351 1592 step=zslongToFix(dstep*100);
11352 1592 newdir();
11353 1592 dashing=false;
11354 1592 }
11355
11356 40922 zfix div = step;
11357
11358
1/2
✓ Branch 0 taken 40922 times.
✗ Branch 1 not taken.
40922 if(div == 0)
11359 div = 1;
11360
11361 40922 clk3=(int32_t)(16.0/div);
11362 40922 return;
11363 }
11364
11365 951705 move(step);
11366 951705 --clk3;
11367 1061272 }
11368
11369 796110 void eStalfos::vire_hop()
11370 {
11371
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11372 {
11373
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11374 {
11375
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11376 3843 }
11377 376292 }
11378 417076 else sclk=0;
11379
11380
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11381 31892 return;
11382
11383 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11384 int32_t jump_height;
11385
11386
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11387 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11388 else jump_height = dmisc10;
11389
11390 761476 y=floor_y;
11391
11392
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11393 {
11394 26258 fix_coords();
11395
11396 //z=0;
11397 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11398 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11399
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11400 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11401
11402
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11403 {
11404 //z=0;
11405
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11406 {
11407
11408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11409 17258 }
11410 21336 }
11411
11412
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11413 {
11414 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11415 7030 }
11416
11417 26258 clk3=int32_t(16.0/step.getFloat());
11418 26258 }
11419
11420 761476 --clk3;
11421
11422
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11423 761476 move(step);
11424
11425 761476 floor_y=y;
11426 761476 clk2--;
11427
11428 //if we're in the middle of a jump
11429
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11430 {
11431 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11432
11433
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11434 {
11435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11436 93147 else z=h;
11437 93147 }
11438 else
11439 {
11440 384731 y=floor_y-h;
11441 384731 shadowdistance=h;
11442 }
11443 477878 }
11444 else
11445 283598 shadowdistance = 0;
11446 796110 }
11447
11448 143 void eStalfos::eathero()
11449 {
11450
5/8
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
143 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11451 {
11452 74 hashero=true;
11453 74 y=floor_y;
11454 74 z=0;
11455
11456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(Hero.isSwimming())
11457 {
11458 Hero.setX(x);
11459 Hero.setY(y);
11460 }
11461 else
11462 {
11463 74 x=Hero.getX();
11464 74 y=Hero.getY();
11465 }
11466
11467 74 clk2=0;
11468 74 }
11469 143 }
11470
11471 1480441 bool eStalfos::WeaponOut()
11472 {
11473
2/2
✓ Branch 0 taken 2414454 times.
✓ Branch 1 taken 626493 times.
3040947 for(int32_t i=0; i<Ewpns.Count(); i++)
11474 {
11475
3/4
✓ Branch 0 taken 853948 times.
✓ Branch 1 taken 1560506 times.
✓ Branch 2 taken 853948 times.
✗ Branch 3 not taken.
2414454 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11476 {
11477 853948 return true;
11478 }
11479 1560506 }
11480
11481 626493 return false;
11482 1480441 }
11483
11484 369776 void eStalfos::KillWeapon()
11485 {
11486
2/2
✓ Branch 0 taken 316707 times.
✓ Branch 1 taken 369776 times.
686483 for(int32_t i=0; i<Ewpns.Count(); i++)
11487 {
11488
4/4
✓ Branch 0 taken 267955 times.
✓ Branch 1 taken 48752 times.
✓ Branch 2 taken 267137 times.
✓ Branch 3 taken 818 times.
316707 if(((weapon*)Ewpns.spr(i))->level==misc && Ewpns.spr(i)->id==ewBrang)
11489 {
11490 //only kill this Goriya's boomerang -DD
11491
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 419 times.
818 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11492 {
11493 419 Ewpns.del(i);
11494 419 }
11495 818 }
11496 316707 }
11497 369776 }
11498
11499 void eStalfos::break_shield()
11500 {
11501 if(!shield)
11502 return;
11503
11504 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11505 shield=false;
11506
11507 if(get_qr(qr_BRKNSHLDTILES))
11508 o_tile=s_tile;
11509 }
11510
11511 void eStalfos::repair_shield()
11512 {
11513 if (shield)
11514 return;
11515
11516 shield = true;
11517
11518 if (get_qr(qr_BRKNSHLDTILES))
11519 {
11520 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11521 else o_tile = d->tile;
11522 }
11523 }
11524
11525 14404 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11526 14404 {
11527
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 dir=(zc_oldrand()&7)+8;
11528
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 step=0;
11529 14404 movestatus=1;
11530
3/4
✓ Branch 0 taken 11247 times.
✓ Branch 1 taken 3157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11247 times.
14404 if (dmisc1 != 1 && dmisc19 > 0)
11531 {
11532 step = dmisc19/100.0;
11533 movestatus = 1;
11534 }
11535
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if (dmisc1 == 2) movestatus=2;
11536 14404 c=0;
11537 14404 clk4=0;
11538 //nets;
11539
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 init_size_flags();
11540 14404 dummy_int[1]=0;
11541 14404 }
11542
11543 3691183 bool eKeese::animate(int32_t index)
11544 {
11545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3691183 times.
3691183 if(switch_hooked) return enemy::animate(index);
11546
2/4
✓ Branch 0 taken 3691183 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3691183 times.
3691183 if(fallclk||drownclk) return enemy::animate(index);
11547
2/2
✓ Branch 0 taken 131109 times.
✓ Branch 1 taken 3560074 times.
3691183 if(dying)
11548 131109 return Dead(index);
11549
11550
2/2
✓ Branch 0 taken 3532905 times.
✓ Branch 1 taken 27169 times.
3560074 if(clk==0)
11551 {
11552 27169 removearmos(x,y);
11553 27169 }
11554
11555
2/2
✓ Branch 0 taken 1037646 times.
✓ Branch 1 taken 2522428 times.
3560074 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11556 {
11557 1037646 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11558 1037646 }
11559 else
11560 {
11561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2522428 times.
2522428 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11562 2522428 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11563 }
11564
11565
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3439736 times.
3560074 if(dmisc2 == e2tKEESETRIB)
11566 {
11567
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11568 {
11569
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11570 {
11571 105 int32_t kids = guys.Count();
11572 105 bool success = false;
11573 105 int32_t id2=dmisc3;
11574 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11575
11576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11577 {
11578
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11579 {
11580 int guycarryingitem = guys.Count()-1;
11581 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11582 itemguy = false;
11583 }
11584
11585 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11586 105 }
11587
11588 105 stop_bgsfx(index);
11589 105 return true;
11590 }
11591 else
11592 {
11593 86 clk4=0;
11594 }
11595 86 }
11596 120233 }
11597 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11598
3/4
✓ Branch 0 taken 995121 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 995121 times.
3439736 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11599 {
11600
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 308053 times.
995121 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11601 {
11602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11603 {
11604 fakez=int32_t(step/zslongToFix(dstep*100));
11605 // Some variance in keese flight heights when away from Hero
11606 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11607
11608 }
11609 else
11610 {
11611 687068 z=int32_t(step/zslongToFix(dstep*100));
11612 // Some variance in keese flight heights when away from Hero
11613
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11614 }
11615 687068 }
11616 else
11617 {
11618
2/2
✓ Branch 0 taken 149242 times.
✓ Branch 1 taken 158811 times.
308053 if (moveflags & move_use_fake_z)
11619 {
11620 149242 fakez=int32_t(step/zslongToFix(dstep*100));
11621 // Some variance in keese flight heights when away from Hero
11622
2/2
✓ Branch 0 taken 132535 times.
✓ Branch 1 taken 16707 times.
149242 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11623
11624 149242 }
11625 else
11626 {
11627 158811 z=int32_t(step/zslongToFix(dstep*100));
11628 // Some variance in keese flight heights when away from Hero
11629
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11630 }
11631 }
11632 995121 }
11633
11634 3559969 return enemy::animate(index);
11635 3691183 }
11636
11637 2931677 bool eKeese::can_drawshadow() const
11638 {
11639
4/4
✓ Branch 0 taken 1533959 times.
✓ Branch 1 taken 1397718 times.
✓ Branch 2 taken 17822 times.
✓ Branch 3 taken 1516137 times.
2931677 if(get_qr(qr_ENEMIESZAXIS) && step <= 0)
11640 17822 return false;
11641
11642 2913855 return enemy::can_drawshadow();
11643 2931677 }
11644 2246724 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11645 {
11646 2246724 flip = 0;
11647
2/2
✓ Branch 0 taken 1561771 times.
✓ Branch 1 taken 684953 times.
2246724 if(!can_drawshadow())
11648 1561771 return;
11649 684953 int32_t tempy=yofs;
11650 684953 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11651
11652
2/2
✓ Branch 0 taken 166228 times.
✓ Branch 1 taken 518725 times.
684953 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684953 times.
684953 if(!get_qr(qr_ENEMIESZAXIS))
11654 {
11655 yofs+=int32_t(step/zslongToFix(dstep*10));
11656 }
11657
11658 684953 enemy::drawshadow(dest, translucent);
11659 684953 yofs=tempy;
11660 2246724 }
11661
11662 8413799 void eKeese::draw(BITMAP *dest)
11663 {
11664 8413799 update_enemy_frame();
11665 8413799 enemy::draw(dest);
11666 8413799 }
11667
11668 14404 void eKeese::init_size_flags()
11669 {
11670 14404 SIZEflags = d->SIZEflags;
11671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11672
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11673
11674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14404 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11676
11677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11678
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11679
11680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
14404 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11681
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14404 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11682
11683
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14404 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11684 // al_trace("Enemy txsz:%i\n", txsz);
11685
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14404 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11686
11687
11688
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14404 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11689
11690
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11691
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11692 {
11693 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11694 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11695 }
11696
11697
1/2
✓ Branch 0 taken 14404 times.
✗ Branch 1 not taken.
14404 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11698 14404 }
11699
11700 20171 void eWizzrobe::submerge(bool set)
11701 {
11702
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11703 {
11704 20024 hxofs = set?1000:0;
11705 20024 return;
11706 }
11707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11708 147 submerged = set;
11709
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11710 76 hxofs+=1000;
11711 71 else hxofs -= 1000;
11712 20171 }
11713 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11714 5350 {
11715 5350 hxofs = 0;
11716 5350 submerged = false;
11717
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11718 {
11719 case 0:
11720 2992 submerge(true);
11721 2992 fading=fade_invisible;
11722 // Set clk to just before the 'reappear' threshold
11723
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11724 2992 break;
11725
11726 default:
11727 2358 dir=(loadside==right)?right:left;
11728 2358 misc=-3;
11729 2358 break;
11730 }
11731
11732 //netst+2880;
11733 5350 charging=false;
11734 5350 firing=false;
11735 5350 fclk=0;
11736
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11737
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11738 5350 }
11739
11740 2081613 bool eWizzrobe::animate(int32_t index)
11741 {
11742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11743
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11744
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11745 {
11746 38023 return Dead(index);
11747 }
11748
11749
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11750 {
11751 66646 removearmos(x,y);
11752 66646 }
11753
11754
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11755 {
11756 1019220 wizzrobe_attack();
11757 1019220 }
11758 else // Teleporting
11759 {
11760
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11761 {
11762 7084 fading=0;
11763 7084 submerge(false);
11764 7084 solid_update(false);
11765 7084 }
11766
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11767 {
11768 case 0:
11769
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11770 {
11771 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11772 // but should not appear on dungeon walls.
11773
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11774
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11775 {
11776 //2.10 Windrobe
11777 //randomise location and face Hero
11778 224 int32_t t=0;
11779 224 bool placed=false;
11780
11781
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11782 {
11783
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11784 {
11785 280 x=((zc_oldrand()%12)+2)*16;
11786 280 y=((zc_oldrand()%7)+2)*16;
11787 280 }
11788 else
11789 {
11790 87 x=((zc_oldrand()%14)+1)*16;
11791 87 y=((zc_oldrand()%9)+1)*16;
11792 }
11793
11794 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11795
11796
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11797 {
11798 224 placed=true;
11799 224 }
11800
11801 367 ++t;
11802 }
11803
11804
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11805 {
11806
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11807 {
11808 47 dir=down;
11809 47 }
11810 else
11811 {
11812 14 dir=up;
11813 }
11814 61 }
11815 else
11816 {
11817
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11818 {
11819 72 dir=right;
11820 72 }
11821 else
11822 {
11823 91 dir=left;
11824 }
11825 }
11826
11827
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11828 return true;
11829
11830
11831 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11832 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11833 224 }
11834 4486 else place_on_axis(true, dmisc4!=0);
11835 5123 }
11836 else
11837 {
11838 1117 int32_t t=0;
11839 1117 bool placed=false;
11840
11841
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11842 {
11843
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11844 {
11845 1340 x=((zc_oldrand()%12)+2)*16;
11846 1340 y=((zc_oldrand()%7)+2)*16;
11847 1340 }
11848 else
11849 {
11850 1103 x=((zc_oldrand()%14)+1)*16;
11851 1103 y=((zc_oldrand()%9)+1)*16;
11852 }
11853
11854 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11855
11856
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11857 {
11858 1117 placed=true;
11859 1117 }
11860
11861 2443 ++t;
11862 }
11863
11864
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11865 {
11866
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11867 {
11868 238 dir=down;
11869 238 }
11870 else
11871 {
11872 148 dir=up;
11873 }
11874 386 }
11875 else
11876 {
11877
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11878 {
11879 340 dir=right;
11880 340 }
11881 else
11882 {
11883 391 dir=left;
11884 }
11885 }
11886
11887
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11888 return true;
11889 }
11890
11891 6240 fading=fade_flicker;
11892 6240 submerge(false);
11893 6240 solid_update(false);
11894 6240 break;
11895
11896 case 64:
11897 5313 fading=0;
11898 5313 charging=true;
11899 5313 break;
11900
11901 case 73:
11902 5151 charging=false;
11903 5151 firing=40;
11904 5151 break;
11905
11906 case 83:
11907 5006 wizzrobe_attack_for_real();
11908 5006 break;
11909
11910 case 119:
11911 4247 firing=false;
11912 4247 charging=true;
11913 4247 break;
11914
11915 case 128:
11916 4109 fading=fade_flicker;
11917 4109 charging=false;
11918 4109 break;
11919
11920 case 146:
11921 3855 fading=fade_invisible;
11922 3855 submerge(true);
11923 3855 solid_update(false);
11924
11925 [[fallthrough]];
11926 default:
11927
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11928 6249 clk=-1;
11929
11930 987220 break;
11931 }
11932 }
11933
11934 2043590 return enemy::animate(index);
11935 2081613 }
11936
11937 7929 void eWizzrobe::wizzrobe_attack_for_real()
11938 {
11939
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11940 return;
11941
11942
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11943 {
11944 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11945 5946 sfx(firesfx, pan(x));
11946 5946 }
11947
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11948 {
11949 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11950 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11951 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11952 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11953 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11954 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11955 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11956 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11957 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11958 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11959 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11960 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11961 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11962 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11963 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11964 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11965 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11966 //i've compromised by making all old quest use this code chunk by default.
11967
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11968 {
11969 995 sfx(WAV_FIRE, pan(x));
11970
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(x));
11971 else
11972 {
11973
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11974 {
11975 19 case ewFireball: sfx(40, pan(x)); break;
11976 case ewBrang: sfx(4, pan(x)); break; //Ghost.zh has 0?
11977 case ewSword: sfx(20, pan(x)); break; //Ghost.zh has 0?
11978 case ewRock: sfx(51, pan(x)); break;
11979 68 case ewMagic: sfx(32, pan(x)); break;
11980 case ewBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11981 case ewSBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11982 case ewLitBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11983 case ewLitSBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11984 case ewFireTrail: sfx(13, pan(x)); break;
11985 420 case ewFlame: sfx(13, pan(x)); break;
11986 case ewWind: sfx(32, pan(x)); break;
11987 case ewFlame2: sfx(13, pan(x)); break;
11988 case ewFlame2Trail: sfx(13, pan(x)); break;
11989 case ewIce: sfx(44, pan(x)); break;
11990 case ewFireball2: sfx(40, pan(x)); break; //fireball (rising)
11991 default: sfx(WAV_FIRE, pan(x)); break;
11992 }
11993 }
11994 995 }
11995 else
11996 {
11997 sfx(firesfx, pan(x));
11998 }
11999 995 }
12000
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12001 {
12002 971 int32_t bc=0;
12003
12004
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12005 {
12006
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12007 {
12008 5195 ++bc;
12009 5195 }
12010 10497 }
12011
12012
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12013 {
12014 963 int32_t kids = guys.Count();
12015 963 int32_t bats=(zc_oldrand()%3)+1;
12016
12017
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12018 {
12019 // Summon bats (or anything)
12020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12021 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12022 1965 }
12023 963 sfx(firesfx, pan(x));
12024 963 }
12025 971 }
12026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12027 {
12028
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12029 {
12030 return;
12031 }
12032
12033 17 int32_t kids = guys.Count();
12034
12035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12036 {
12037 17 int32_t newguys=(zc_oldrand()%3)+1;
12038 17 bool summoned=false;
12039
12040
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12041 {
12042 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12043 32 int32_t x2=0;
12044 32 int32_t y2=0;
12045
12046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12047 {
12048 36 x2=16*((zc_oldrand()%12)+2);
12049 36 y2=16*((zc_oldrand()%7)+2);
12050
12051
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12052 {
12053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12054 {
12055 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12056
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12057 {
12058 ((enemy*)guys.spr(kids+i))->fakez = 64;
12059 ((enemy*)guys.spr(kids+i))->z = 0;
12060 }
12061 32 }
12062
12063 32 summoned=true;
12064 32 break;
12065 }
12066 4 }
12067 32 }
12068
12069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12070 {
12071 17 sfx(firesfx, pan(x));
12072 17 }
12073 17 }
12074 17 }
12075 7929 }
12076
12077
12078 1019220 void eWizzrobe::wizzrobe_attack()
12079 {
12080
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12081 86341 return;
12082
12083
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12084 {
12085 39538 fix_coords();
12086
12087
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12088 {
12089 case 1: //walking
12090
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12091 2644 misc=0;
12092 else
12093 {
12094 10364 clk3=16;
12095
12096
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12097 {
12098 1398 wizzrobe_newdir(0);
12099 1398 }
12100 }
12101
12102 13008 break;
12103
12104 case 2: //phasing
12105 {
12106 3903 int32_t jx=x;
12107 3903 int32_t jy=y;
12108 3903 int32_t jdir=-1;
12109
12110
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12111 {
12112 case 0:
12113 484 jx-=32;
12114 484 jy-=32;
12115 484 jdir=15;
12116 484 break;
12117
12118 case 1:
12119 472 jx+=32;
12120 472 jy-=32;
12121 472 jdir=9;
12122 472 break;
12123
12124 case 2:
12125 482 jx+=32;
12126 482 jy+=32;
12127 482 jdir=11;
12128 482 break;
12129
12130 case 3:
12131 492 jx-=32;
12132 492 jy+=32;
12133 492 jdir=13;
12134 492 break;
12135 }
12136
12137
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12138 {
12139 1140 misc=3;
12140 1140 clk3=32;
12141 1140 dir=jdir;
12142 1140 break;
12143 }
12144 2763 }
12145 [[fallthrough]];
12146 case 3:
12147 3813 dir&=3;
12148 3813 misc=0;
12149 [[fallthrough]];
12150 case 0:
12151 19894 wizzrobe_newdir(64);
12152 [[fallthrough]];
12153 default:
12154
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12155 {
12156
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12157 {
12158 3265 misc=1;
12159 3265 clk3=16;
12160 3265 }
12161 else
12162 {
12163 239 wizzrobe_newdir(64);
12164 239 misc=0;
12165 239 clk3=32;
12166 }
12167 3504 }
12168 else
12169 {
12170 21886 clk3=32;
12171 }
12172
12173 25390 break;
12174 }
12175
12176
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12177 4478 ++misc;
12178 39538 }
12179
12180 932879 --clk3;
12181
12182
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12183 {
12184 case 1:
12185 case 3:
12186 248377 step=1;
12187 248377 break;
12188
12189 case 2:
12190 63903 step=0;
12191 63903 break;
12192
12193 default:
12194 620599 step=0.5;
12195 620599 break;
12196
12197 }
12198
12199 932879 move(step);
12200
12201 // if(d->misc1 && misc<=0 && clk3==28)
12202
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12203 {
12204
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12205 {
12206
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12207 {
12208 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12209 // sfx(WAV_WAND,pan(x));
12210 1928 wizzrobe_attack_for_real();
12211 1928 fclk=30;
12212 1928 }
12213 16835 }
12214 else
12215 {
12216
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12217 {
12218 995 wizzrobe_attack_for_real();
12219 995 fclk=30;
12220 995 }
12221 }
12222 21547 }
12223
12224
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12225 4050 misc=2;
12226
12227
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12228 3441 fix_coords();
12229
12230
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12231 {
12232
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12233 {
12234 83282 --fclk;
12235 83282 }
12236 932879 }
12237
12238 1019220 }
12239
12240 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12241 {
12242 // Wizzrobes shouldn't move to the edge of the screen;
12243 // if they're already there, they should move toward the center
12244
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12245 33 dir=right;
12246
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12247 4 dir=left;
12248
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12249 2 dir=down;
12250
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12251 5 dir=up;
12252 else
12253 21487 newdir(4,homing,spw_wizzrobe);
12254 21531 }
12255
12256 2099229 void eWizzrobe::draw(BITMAP *dest)
12257 {
12258 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12259
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12260 125018 return;
12261
12262 1974211 int32_t tempint=dummy_int[1];
12263 1974211 bool tempbool1=dummy_bool[1];
12264 1974211 bool tempbool2=dummy_bool[2];
12265 1974211 dummy_int[1]=fclk;
12266 1974211 dummy_bool[1]=charging;
12267 1974211 dummy_bool[2]=firing;
12268 1974211 update_enemy_frame();
12269 1974211 dummy_int[1]=tempint;
12270 1974211 dummy_bool[1]=tempbool1;
12271 1974211 dummy_bool[2]=tempbool2;
12272 1974211 enemy::draw(dest);
12273 2099229 }
12274
12275 209 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12276 209 {
12277 209 fading=fade_flash_die;
12278
6/8
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 50 times.
209 if(dir==down&&y>=128)
12279 {
12280 4 dir=up;
12281 4 }
12282
12283
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
209 if(dir==right&&x>=208)
12284 {
12285 dir=left;
12286 }
12287
1/4
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209 if (SIZEflags != 0) init_size_flags();;
12288 209 }
12289
12290 133094 bool eDodongo::animate(int32_t index)
12291 {
12292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133094 times.
133094 if(switch_hooked) return enemy::animate(index);
12293
2/2
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 129040 times.
133094 if(dying)
12294 {
12295 4054 return Dead(index);
12296 }
12297
12298
2/2
✓ Branch 0 taken 128441 times.
✓ Branch 1 taken 599 times.
129040 if(clk==0)
12299 {
12300 599 removearmos(x,y);
12301 599 }
12302
12303
2/2
✓ Branch 0 taken 11424 times.
✓ Branch 1 taken 117616 times.
129040 if(clk2) // ate a bomb
12304 {
12305
2/2
✓ Branch 0 taken 11305 times.
✓ Branch 1 taken 119 times.
11424 if(--clk2==0)
12306 119 hp-=misc; // store bomb's power in misc
12307 11424 }
12308 else
12309 117616 constant_walk(rate,homing,spw_clipright);
12310
12311 129040 hit_width = (dir<=down) ? 16 : 32;
12312 // hysz = (dir>=left) ? 16 : 32;
12313
12314 129040 return enemy::animate(index);
12315 133094 }
12316
12317 133544 void eDodongo::draw(BITMAP *dest)
12318 {
12319 133544 tile=o_tile;
12320
12321
2/2
✓ Branch 0 taken 3077 times.
✓ Branch 1 taken 130467 times.
133544 if(clk<0)
12322 {
12323 3077 enemy::drawzcboss(dest);
12324 3077 return;
12325 }
12326
12327 130467 update_enemy_frame();
12328 130467 enemy::drawzcboss(dest);
12329
12330
2/2
✓ Branch 0 taken 54026 times.
✓ Branch 1 taken 76441 times.
130467 if(dummy_int[1]!=0) //additional tiles
12331 {
12332 76441 tile+=dummy_int[1]; //second tile is previous tile
12333 76441 xofs-=16; //new xofs change
12334 76441 enemy::drawzcboss(dest);
12335 76441 xofs+=16;
12336 76441 }
12337
12338 133544 }
12339
12340 8681 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12341 {
12342 8681 int32_t wpnId = w->id;
12343 8681 int32_t power = w->power;
12344 8681 int32_t wpnx = w->x;
12345 8681 int32_t wpny = w->y;
12346
12347
5/12
✓ Branch 0 taken 8681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8681 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2676 times.
✓ Branch 5 taken 6005 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2676 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8681 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12348 6005 return 0;
12349
12350
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 851 times.
✓ Branch 2 taken 1631 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 177 times.
2676 switch(wpnId)
12351 {
12352 case wPhantom:
12353 return 0;
12354
12355 case wFire:
12356 case wBait:
12357 case wWhistle:
12358 case wWind:
12359 case wSSparkle:
12360 case wFSparkle:
12361 return 0;
12362
12363 case wLitBomb:
12364 case wLitSBomb:
12365
6/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 564 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 732 times.
✓ Branch 5 taken 119 times.
851 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12366 732 return 0;
12367
12368 119 clk2=96;
12369 119 misc=power;
12370
12371
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 3 times.
119 if(wpnId==wLitSBomb)
12372 3 item_set=isSBOMB100;
12373
12374 119 return 1;
12375
12376 case wBomb:
12377 case wSBomb:
12378
6/6
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 1095 times.
✓ Branch 2 taken 463 times.
✓ Branch 3 taken 1168 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 1044 times.
1631 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12379 587 return 0;
12380
12381 1044 stunclk=160;
12382 1044 misc=wpnId; // store wpnId
12383 1044 return 1;
12384
12385 case wSword:
12386
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 92 times.
177 if(stunclk)
12387 {
12388 92 sfx(WAV_EHIT,pan(x));
12389 92 hp=0;
12390 92 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12391 92 fading=0; // don't flash
12392 92 return 1;
12393 }
12394
12395 [[fallthrough]];
12396 default:
12397 102 sfx(WAV_CHINK,pan(x));
12398 102 }
12399
12400 102 return 1;
12401 8681 }
12402
12403 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12404 48 {
12405 48 fading=fade_flash_die;
12406 //nets+5180;
12407 48 previous_dir=-1;
12408
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12409 {
12410 1 dir=up;
12411 1 }
12412
12413
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12414 {
12415 dir=left;
12416 }
12417
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12418 48 }
12419
12420 39398 bool eDodongo2::animate(int32_t index)
12421 {
12422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12423
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12424 {
12425 1158 return Dead(index);
12426 }
12427
12428
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12429 {
12430 167 removearmos(x,y);
12431 167 }
12432
12433
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12434 {
12435
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12436 42 hp-=misc; // store bomb's power in misc
12437 4032 }
12438 else
12439 34208 constant_walk(rate,homing,spw_clipbottomright);
12440
12441 38240 hit_width = (dir<=down) ? 16 : 32;
12442 38240 hit_height = (dir>=left) ? 16 : 32;
12443 38240 hxofs=(dir>=left)?-8:0;
12444 38240 hyofs=(dir<left)?-8:0;
12445
12446 38240 return enemy::animate(index);
12447 39398 }
12448
12449 39601 void eDodongo2::draw(BITMAP *dest)
12450 {
12451
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12452 {
12453 768 enemy::drawzcboss(dest);
12454 768 return;
12455 }
12456
12457 38833 int32_t tempx=xofs;
12458 38833 int32_t tempy=yofs;
12459 38833 update_enemy_frame();
12460 38833 enemy::drawzcboss(dest);
12461 38833 tile+=dummy_int[1]; //second tile change
12462 38833 xofs+=dummy_int[2]; //new xofs change
12463 38833 yofs+=dummy_int[3]; //new yofs change
12464 38833 enemy::drawzcboss(dest);
12465 38833 xofs=tempx;
12466 38833 yofs=tempy;
12467 39601 }
12468
12469 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12470 {
12471 3929 int32_t wpnId = w->id;
12472 3929 int32_t power = w->power;
12473 3929 int32_t wpnx = w->x;
12474 3929 int32_t wpny = w->y;
12475
12476
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12477 2377 return 0;
12478
12479
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12480 {
12481 case wPhantom:
12482 return 0;
12483
12484 case wFire:
12485 case wBait:
12486 case wWhistle:
12487 case wWind:
12488 case wSSparkle:
12489 case wFSparkle:
12490 346 return 0;
12491
12492 case wLitBomb:
12493 case wLitSBomb:
12494
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12495 {
12496 case up:
12497
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12498 77 return 0;
12499
12500 4 break;
12501
12502 case down:
12503
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12504 71 return 0;
12505
12506 6 break;
12507
12508 case left:
12509
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12510 66 return 0;
12511
12512 16 break;
12513
12514 case right:
12515
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12516 65 return 0;
12517
12518 16 break;
12519 }
12520
12521 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12522 // return 0;
12523 42 clk2=96;
12524 42 misc=power;
12525
12526
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12527 item_set=isSBOMB100;
12528
12529 42 return 1;
12530
12531 case wBomb:
12532 case wSBomb:
12533
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12534 {
12535 case up:
12536
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12537 84 return 0;
12538
12539 92 break;
12540
12541 case down:
12542
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12543 113 return 0;
12544
12545 55 break;
12546
12547 case left:
12548
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12549 80 return 0;
12550
12551 105 break;
12552
12553 case right:
12554
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12555 71 return 0;
12556
12557 93 break;
12558 }
12559
12560 345 stunclk=160;
12561 345 misc=wpnId; // store wpnId
12562 345 return 1;
12563
12564 case wSword:
12565
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12566 {
12567 34 sfx(WAV_EHIT,pan(x));
12568 34 hp=0;
12569 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12570 34 fading=0; // don't flash
12571 34 return 1;
12572 }
12573
12574 [[fallthrough]];
12575 default:
12576 158 sfx(WAV_CHINK,pan(x));
12577 158 }
12578
12579 158 return 1;
12580 3929 }
12581
12582 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12583 126 {
12584 //these are here to bypass compiler warnings about unused arguments
12585
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12586 {
12587
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12588 126 }
12589 else { x = X; y = Y; }
12590
12591 //nets+5940;
12592
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12593 {
12594 81 }
12595 else
12596 {
12597
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12598 {
12599 7 flip=1;
12600 7 }
12601 }
12602
12603
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12604 126 clk3=32;
12605 126 clk2=0;
12606 126 clk4=clk;
12607 126 dir=left;
12608
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12609 126 }
12610
12611 71899 bool eAquamentus::animate(int32_t index)
12612 {
12613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12614
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12615 2092 return Dead(index);
12616
12617 // fbx=x+((id==eRAQUAM)?4:-4);
12618
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12619 {
12620 317 removearmos(x,y);
12621 317 }
12622
12623 69807 fbx=x;
12624
12625 /*
12626 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12627 {
12628 fbx+=16;
12629 }
12630 */
12631
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12632 {
12633 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12634 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12635 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12636 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12637 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12638 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12639 450 sfx(wpnsfx(wpn),pan(x));
12640 450 }
12641
12642
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12643 {
12644 345 clk3=32;
12645 345 }
12646
12647 69807 int screen_x = x.getInt()%256;
12648
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12649 {
12650 1117 int32_t d2=(zc_oldrand()%3)+1;
12651
12652
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12653 {
12654 752 dir=d2;
12655 752 }
12656
12657
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12658 {
12659
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12660 {
12661 38 dir=right;
12662 38 }
12663
12664
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12665 {
12666 dir=left;
12667 }
12668 385 }
12669 else
12670 {
12671
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12672 {
12673 21 dir=right;
12674 21 }
12675
12676
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12677 {
12678 34 dir=left;
12679 34 }
12680 }
12681 1117 }
12682
12683
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12684 {
12685
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12686 {
12687 4546 x-=1;
12688 4546 }
12689 else
12690 {
12691 3995 x+=1;
12692 }
12693 8541 }
12694
12695 69807 clk4=(clk4+1)%256;
12696
12697 69807 return enemy::animate(index);
12698 71899 }
12699
12700 72310 void eAquamentus::draw(BITMAP *dest)
12701 {
12702
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12703 {
12704 44994 xofs=(dmisc1?-16:0);
12705
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12706
12707
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12708 {
12709 1312 xofs=0;
12710 1312 enemy::draw(dest);
12711 1312 }
12712 else
12713 {
12714 43682 drawblock(dest,15);
12715 }
12716 44994 }
12717 else
12718 {
12719 27316 int32_t xblockofs=((dmisc1)?-16:16);
12720 27316 xofs=0;
12721
12722
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12723 {
12724 1462 enemy::draw(dest);
12725 1462 return;
12726 }
12727
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12728 {
12729 // face (0=firing, 2=resting)
12730 25854 tile=o_tile+((clk3>0)?0:2);
12731 25854 enemy::draw(dest);
12732 // tail (
12733 25854 tile=o_tile+((clk&16)?1:3);
12734 25854 xofs=xblockofs;
12735 25854 enemy::draw(dest);
12736 // body
12737 25854 yofs+=16;
12738 25854 xofs=0;
12739 25854 tile=o_tile+((clk&16)?20:22);
12740 25854 enemy::draw(dest);
12741 25854 xofs=xblockofs;
12742 25854 tile=o_tile+((clk&16)?21:23);
12743 25854 enemy::draw(dest);
12744 25854 yofs-=16;
12745 25854 }
12746 else enemy::draw(dest);
12747 }
12748 72310 }
12749
12750 23834 bool eAquamentus::hit(weapon *w)
12751 {
12752
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12753
12754
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12755 {
12756 case wBeam:
12757 case wRefBeam:
12758 case wMagic:
12759 4201 hit_height=32;
12760 4201 }
12761
12762
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12763 23834 hit_height=16;
12764 23834 return ret;
12765
12766 23834 }
12767
12768 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12769 93 {
12770
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12771 {
12772
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12773 93 }
12774 else { x = X; y = Y; }
12775
12776 93 Clk=Clk;
12777
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12778 {
12779 clk=0;
12780 superman = 1;
12781 fading=fade_flicker;
12782 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12783 }
12784
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12785 {
12786 42 clk=0;
12787 42 }
12788 93 hxofs=-16;
12789 93 hit_width=48;
12790 93 clk4=0;
12791
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12792
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12794
12795 //nets+5340;
12796 93 }
12797
12798 70891 bool eGohma::animate(int32_t index)
12799 {
12800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12801
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12802 1226 return Dead(index);
12803
12804
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12805 {
12806
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12807 {
12808 35 clk4=0;
12809 35 superman=0;
12810 35 fading=0;
12811 35 clk=0;
12812
12813 35 }
12814 1 else return enemy::animate(index);
12815 35 }
12816
12817
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12818 {
12819
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 if (activated_handle && !activated_handle->is_rpos()) removearmos(x,y);
12820 else
12821 {
12822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12823 350 did_armos = false;
12824 350 removearmos(x,y);
12825 350 did_armos = false;
12826
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12827 }
12828 350 }
12829
12830
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12831
12832 // Movement clk must be separate from animation clk because of the Clock item
12833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12834 68878 clk4++;
12835
12836
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12837 {
12838
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12839 546 dir^=1;
12840 else
12841 486 dir=zc_oldrand()%3+1;
12842 1032 }
12843
12844
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12845 {
12846
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12847 {
12848 case 1:
12849 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12850 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12851 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12852 235 sfx(wpnsfx(wpn),pan(x));
12853 235 break;
12854
12855 default:
12856
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12857 {
12858 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12859 754 sfx(wpnsfx(wpn),pan(x));
12860 754 sfx(wpnsfx(wpn),pan(x));
12861 754 }
12862
12863 882 break;
12864 }
12865 1117 }
12866
12867
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12868 {
12869
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12870 {
12871 290 FireBreath(true);
12872 290 }
12873 2215 }
12874
12875
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12876 34479 move((zfix)1);
12877
12878
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12879 150 clk3=0;
12880
12881 68878 return enemy::animate(index);
12882 70891 }
12883
12884 70889 void eGohma::draw(BITMAP *dest)
12885 {
12886 70889 tile=o_tile;
12887
12888
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12889 {
12890 2012 enemy::drawzcboss(dest);
12891 2012 return;
12892 }
12893
12894
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12895 {
12896 ///if ( do_animation )
12897 //Yuck. Gohma can just not have this capability right now.
12898 // left side
12899 53472 xofs=-16;
12900 53472 flip=0;
12901 // if(clk&16) tile=180;
12902 // else { tile=182; flip=1; }
12903 53472 tile+=(3*((clk&48)>>4));
12904 53472 enemy::drawzcboss(dest);
12905
12906 // right side
12907 53472 xofs=16;
12908 // tile=(180+182)-tile;
12909 53472 tile=o_tile;
12910 53472 tile+=(3*((clk&48)>>4))+2;
12911 53472 enemy::drawzcboss(dest);
12912
12913 // body
12914 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12915 53472 tile=o_tile;
12916
12917 // tile+=(3*((clk&24)>>3))+2;
12918
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12919 2975 tile+=7;
12920
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12921 15890 tile+=10;
12922
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12923 2051 tile+=7;
12924 else
12925 32556 tile+=((clk3-132)&24)?4:1;
12926
12927 53472 enemy::drawzcboss(dest);
12928
12929 53472 }
12930 else
12931 {
12932 // left side
12933 15405 xofs=-16;
12934 15405 flip=0;
12935
12936
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12937 {
12938 7790 tile+=2;
12939 7790 flip=1;
12940 7790 }
12941
12942 15405 enemy::draw(dest);
12943
12944 // right side
12945 15405 tile=o_tile;
12946 15405 xofs=16;
12947
12948
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12949
12950 // tile=(180+182)-tile;
12951 15405 enemy::draw(dest);
12952
12953 // body
12954 15405 tile=o_tile;
12955 15405 xofs=0;
12956
12957
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12958 912 tile+=4;
12959
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12960 4882 tile+=5;
12961
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12962 585 tile+=4;
12963 9026 else tile+=((clk3-132)&8)?3:1;
12964
12965 15405 enemy::draw(dest);
12966
12967 }
12968 70889 }
12969
12970 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12971 {
12972 578 int32_t wpnId = w->id;
12973 578 int32_t power = w->power;
12974 578 int32_t wpnx = w->x;
12975 578 int32_t wpnDir = w->dir;
12976 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12977
12978
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12979 {
12980
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12981 {
12982 93 sfx(WAV_CHINK,pan(x));
12983 93 return 1;
12984 }
12985 328 }
12986
12987 485 return enemy::takehit(w, realweap);
12988 578 }
12989
12990 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12991 327 {
12992 327 count_enemy=(id==(id&0xFFF));
12993 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
12994
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
12995 327 }
12996
12997 124050 bool eLilDig::animate(int32_t index)
12998 {
12999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13000
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13001 4410 return Dead(index);
13002
13003
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13004 {
13005 7105 removearmos(x,y);
13006 7105 }
13007
13008
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13009 {
13010
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13011 1161 step+=0.25;
13012 38646 }
13013
13014 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13015 119640 return enemy::animate(index);
13016 124050 }
13017
13018 124268 void eLilDig::draw(BITMAP *dest)
13019 {
13020 124268 tile = o_tile;
13021 // tile = 160;
13022 124268 int32_t fdiv = frate/4;
13023
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13024
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13025 124268 efrate:((clk>=(frate>>1))?1:0);
13026
13027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13028 {
13029
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13030 {
13031
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13032 {
13033 case up: //u
13034 11370 flip=0;
13035 11370 break;
13036
13037 case l_up: //d
13038 10699 flip=0;
13039 10699 tile+=4;
13040 10699 break;
13041
13042 case l_down: //l
13043 10722 flip=0;
13044 10722 tile+=8;
13045 10722 break;
13046
13047 case left: //r
13048 12015 flip=0;
13049 12015 tile+=12;
13050 12015 break;
13051
13052 case r_down: //ul
13053 10070 flip=0;
13054 10070 tile+=20;
13055 10070 break;
13056
13057 case down: //ur
13058 9554 flip=0;
13059 9554 tile+=24;
13060 9554 break;
13061
13062 case r_up: //dl
13063 8255 flip=0;
13064 8255 tile+=28;
13065 8255 break;
13066
13067 case right: //dr
13068 10033 flip=0;
13069 10033 tile+=32;
13070 10033 break;
13071 }
13072
13073 91457 tile+=f2;
13074 91457 }
13075 else
13076 {
13077 32811 tile+=(clk>=6)?1:0;
13078 }
13079 124268 }
13080
13081 124268 enemy::draw(dest);
13082 124268 }
13083
13084 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13085 80 {
13086
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13087 80 }
13088
13089 29662 bool eBigDig::animate(int32_t index)
13090 {
13091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13093 return Dead(index);
13094
13095
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13096 {
13097 4104 removearmos(x,y);
13098 4104 }
13099
13100
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13101 {
13102 case 0:
13103 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13104 29534 break;
13105
13106 case 1:
13107 64 ++misc;
13108 64 break;
13109
13110 case 2:
13111
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13112 {
13113 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13114 111 }
13115
13116
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13117 {
13118 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13119 30 }
13120
13121
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13122 {
13123 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13124 30 }
13125
13126
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13127 {
13128 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13129 30 }
13130
13131
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13132 {
13133 2 int guycarryingitem = guys.Count()-1;
13134 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13135 2 itemguy = false;
13136 2 }
13137
13138 64 stop_bgsfx(index);
13139
13140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(x));
13141
13142 64 return true;
13143 }
13144
13145 29598 return enemy::animate(index);
13146 29662 }
13147
13148 29658 void eBigDig::draw(BITMAP *dest)
13149 {
13150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13151 {
13152 update_enemy_frame();
13153 xofs-=8;
13154 yofs-=8;
13155 drawblock(dest,15);
13156 xofs+=8;
13157 yofs+=8;
13158 return;
13159 }
13160
13161 29658 tile = o_tile;
13162 29658 int32_t fdiv = frate/4;
13163
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13164
13165
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13166 29658 efrate:((clk>=(frate>>1))?1:0);
13167
13168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13169 {
13170
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13171 {
13172
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13173 {
13174 case up: //u
13175 1688 flip=0;
13176 1688 break;
13177
13178 case l_up: //d
13179 1684 flip=0;
13180 1684 tile+=8;
13181 1684 break;
13182
13183 case l_down: //l
13184 2031 flip=0;
13185 2031 tile+=40;
13186 2031 break;
13187
13188 case left: //r
13189 1910 flip=0;
13190 1910 tile+=48;
13191 1910 break;
13192
13193 case r_down: //ul
13194 2041 flip=0;
13195 2041 tile+=80;
13196 2041 break;
13197
13198 case down: //ur
13199 2043 flip=0;
13200 2043 tile+=88;
13201
13202 2043 break;
13203
13204 case r_up: //dl
13205 1514 flip=0;
13206 1514 tile+=120;
13207 1514 break;
13208
13209 case right: //dr
13210 2241 flip=0;
13211 2241 tile+=128;
13212 2241 break;
13213 }
13214
13215 16161 tile+=(f2*2);
13216 16161 }
13217 else
13218 {
13219 13497 tile+=(f2)?0:2;
13220 13497 flip=(clk&1)?1:0;
13221 }
13222 29658 }
13223
13224 29658 xofs-=8;
13225 29658 yofs-=8;
13226 29658 drawblock(dest,15);
13227 29658 xofs+=8;
13228 29658 yofs+=8;
13229 29658 }
13230
13231 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13232 {
13233 869 int32_t wpnId = w->id;
13234
13235
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13236 {
13237 64 misc = 1;
13238 64 w->hit_pierce(this, 0, false);
13239 64 }
13240
13241 869 return 0;
13242 }
13243
13244 80 void eBigDig::init_size_flags()
13245 {
13246 80 SIZEflags = d->SIZEflags;
13247
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13248 // al_trace("Enemy txsz:%i\n", txsz);
13249
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13250
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13251 80 else hit_width = 32;
13252
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13253 80 else hit_height = 32;
13254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13255 80 else hzsz = 16; // hard to jump.
13256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13257 80 else hxofs = -8;
13258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13259 80 else hyofs = -8;
13260 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13261
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13262
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13263 {
13264 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13265 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13266 }
13267
13268
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13269 80 }
13270
13271 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13272 13 {
13273 13 hxofs=hyofs=8;
13274
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13275 {
13276 hxofs = 4;
13277 hyofs = 4;
13278 hit_width = 24;
13279 hit_height = 24;
13280 SIZEflags|=OVERRIDE_HIT_WIDTH;
13281 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13282 }
13283 13 hzsz=16; //can't be jumped.
13284 13 clk2=70;
13285 13 misc=-1;
13286
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13287
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13288 13 }
13289
13290 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13291 {
13292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13293
13294 return Dead(index);
13295
13296
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13297 {
13298 72 removearmos(x,y);
13299 72 }
13300
13301
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13302 {
13303 case -1:
13304 13 misc=0;
13305 [[fallthrough]];
13306 case 0:
13307
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13308 {
13309 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13310 173 sfx(wpnsfx(wpn),pan(x));
13311 173 clk2=0;
13312 173 }
13313
13314 12693 Stunclk=0;
13315 12693 constant_walk(rate,homing,spw_none);
13316 12693 break;
13317
13318 case 1:
13319 case 2:
13320
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13321 {
13322 41 int32_t r=zc_oldrand();
13323
13324
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13325 {
13326 17 y=96;
13327
13328
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13329 6 x=160;
13330 else
13331 11 x=48;
13332
13333
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13334 8 x=208-x;
13335
13336 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13337 17 }
13338
13339 41 loadpalset(csBOSS,pSprite(d->bosspal));
13340 41 misc=0;
13341 41 }
13342
13343 3607 break;
13344
13345 case 3:
13346 {
13347
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13348 972 break;
13349
13350 12 misc=4;
13351 12 clk=0;
13352 12 hxofs=1000;
13353 12 loadpalset(9,pSprite(spPILE));
13354 12 music_stop();
13355 12 stop_sfx(WAV_ROAR);
13356
13357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(x));
13358
13359 12 sfx(WAV_GANON);
13360 //Ganon's dustpile; fall in sideview. -Z
13361 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13362 //dustpile->miscellaneous[31] = eeGANON;
13363
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13364 12 item *dustpile = NULL;
13365 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13366 12 dustpile = (item *)items.spr(items.Count() - 1);
13367 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13368 12 break;
13369 }
13370
13371 case 4:
13372
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13373 {
13374 12 misc=5;
13375
13376 //game->lvlitems[dlevel]|=(1 << li_boss_killed);
13377
13378 12 sfx(WAV_CLEARED);
13379 //Add the big TF over the ashes!
13380
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13381 {
13382 24 item *ashes = (item*)items.spr(q);
13383
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13384 {
13385 //Z_scripterrlog("Found correct dustpile!\n");
13386
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13387 12 item *bigtriforce = NULL;
13388 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13389 12 bigtriforce->linked_parent = eeGANON;
13390 12 }
13391 24 }
13392 12 }
13393
13394 960 break;
13395 10 case 5: return true;
13396 }
13397
13398 18244 return enemy::animate(index);
13399 18254 }
13400
13401
13402 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13403 {
13404 //these are here to bypass compiler warnings about unused arguments
13405 964 int32_t wpnId = w->id;
13406 964 int32_t power = w->power;
13407 964 int32_t enemyHitWeapon = w->parentitem;
13408
13409
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13410 {
13411 case 0:
13412
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13413 31 return 0;
13414
13415 53 hp-=power;
13416
13417
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13418 {
13419 41 misc=1;
13420 41 Stunclk=64;
13421 41 }
13422 else
13423 {
13424 12 loadpalset(csBOSS,pSprite(spBROWN));
13425 12 misc=2;
13426 12 Stunclk=284;
13427 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13428 }
13429
13430 53 sfx(WAV_EHIT,pan(x));
13431
13432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(x));
13433
13434 53 return 1;
13435
13436 case 2:
13437
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13438 154 return 0;
13439
13440 12 misc=3;
13441 12 hclk=81;
13442 12 loadpalset(9,pSprite(spBROWN));
13443 12 return 1;
13444 }
13445
13446 714 return 0;
13447 964 }
13448
13449 20776 void eGanon::draw(BITMAP *dest)
13450 {
13451
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13452 {
13453 case 0:
13454
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13455 3169 tile=(zc_oldrand()%5)*2+o_tile;
13456
13457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13458 {
13459
13460 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13461 {
13462 int odraw = drawstyle;
13463 drawstyle = 2;
13464 drawblock(dest,15);
13465 drawstyle = odraw;
13466 }
13467 else
13468 {
13469 drawblock(dest,15);
13470 }
13471 break;
13472
13473 }
13474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13475 {
13476 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13477 {
13478 int odraw = drawstyle;
13479 drawstyle = 2;
13480 drawblock(dest,15);
13481 drawstyle = odraw;
13482 }
13483 else
13484 {
13485 drawblock(dest,15);
13486 }
13487 break;
13488 }
13489
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13490 12680 break;
13491 [[fallthrough]];
13492 case 2:
13493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13494 break;
13495 [[fallthrough]];
13496 case -1:
13497 3518 tile=o_tile;
13498
13499 [[fallthrough]];
13500 case 1:
13501 case 3:
13502 7126 drawblock(dest,15);
13503 7126 break;
13504
13505 case 4:
13506 960 draw_guts(dest);
13507 960 draw_flash(dest);
13508 960 break;
13509 }
13510 20776 }
13511
13512 960 void eGanon::draw_guts(BITMAP *dest)
13513 {
13514
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13515 960 tile = clk<24 ? 74 : 75;
13516 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13517 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13518 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13519 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13520 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13521 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13522 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13523 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13524 960 }
13525
13526 960 void eGanon::draw_flash(BITMAP *dest)
13527 {
13528
13529 960 int32_t c = clk-(clk>>2);
13530 960 cs = (frame&3)+6;
13531 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13532 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13533 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13534 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13535 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13536 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13537 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13538 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13539 960 }
13540
13541 19 void getBigTri(mapscr* scr, int32_t id2)
13542 {
13543 /*
13544 *************************
13545 * BIG TRIFORCE SEQUENCE *
13546 *************************
13547 0 BIGTRI out, WHITE flash in
13548 4 WHITE flash out, PILE cset white
13549 8 WHITE in
13550 ...
13551 188 WHITE out
13552 191 PILE cset red
13553 200 top SHUTTER opens
13554 209 bottom SHUTTER opens
13555 */
13556 19 sfx(itemsbuf[id2].playsound);
13557 19 guys.clear();
13558
13559
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(itemsbuf[id2].flags & item_gamedata)
13560 {
13561 4 game->lvlitems[dlevel]|=(1 << li_mcguffin);
13562 4 }
13563
13564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13565
13566 19 draw_screen();
13567
13568
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 3648 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 3648 times.
3667 for(int32_t f=0; f<24*8 && !Quit; f++)
13569 {
13570
2/2
✓ Branch 0 taken 3629 times.
✓ Branch 1 taken 19 times.
3648 if(f==4)
13571 {
13572
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 19 times.
304 for(int32_t i=1; i<16; i++)
13573 {
13574 285 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13575 285 }
13576 19 }
13577
13578
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 456 times.
3648 if((f&7)==0)
13579 {
13580
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 456 times.
1824 for(int32_t cs=2; cs<5; cs++)
13581 {
13582
2/2
✓ Branch 0 taken 20520 times.
✓ Branch 1 taken 1368 times.
21888 for(int32_t i=1; i<16; i++)
13583 {
13584 20520 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13585 20520 }
13586 1368 }
13587
13588 456 refreshpal=true;
13589 456 }
13590
13591
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 456 times.
3648 if((f&7)==4)
13592 {
13593
1/2
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
456 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13594 else loadlvlpal(0xB);
13595 456 }
13596
13597
2/2
✓ Branch 0 taken 3629 times.
✓ Branch 1 taken 19 times.
3648 if(f==191)
13598 {
13599 19 loadpalset(9,pSprite(spPILE));
13600 19 }
13601
13602 3648 advanceframe(true);
13603 3648 }
13604
13605 //play_DmapMusic();
13606 19 playLevelMusic();
13607
13608
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
19 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13609 {
13610 6 Hero.dowarp(hero_scr, 1, 0); //side warp
13611 6 }
13612 19 }
13613
13614 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13615 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13616 618 {
13617
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13618 {
13619
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13620 618 }
13621 //else { x = X; y = Y; }
13622
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13623 618 superman=1;
13624 618 fading=fade_invisible;
13625 618 hxofs=1000;
13626 618 segcnt=clk;
13627 618 segid=Id|0x1000;
13628 618 clk=0;
13629
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13630
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13631 618 tile=o_tile;
13632 618 hitdir = -1;
13633 618 stickclk = 0;
13634
13635 /*
13636 if (get_qr(qr_NEWENEMYTILES))
13637 {
13638 tile=nets+1220;
13639 }
13640 else
13641 {
13642 tile=57;
13643 }
13644 */
13645 618 }
13646
13647 244844 bool eMoldorm::animate(int32_t index)
13648 {
13649 244844 update_current_screen();
13650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13651 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13652
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13653 {
13654 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13655 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13656 28475 }
13657
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13658 {
13659 562 stickclk = 0;
13660 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13661 562 }
13662
13663
13664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13665 {
13666 244844 removearmos(x,y);
13667 244844 }
13668
13669
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13670 {
13671
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13672 {
13673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13674 129 never_return(screen_spawned, index);
13675
13676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13677 129 leave_item();
13678
13679 129 stop_bgsfx(index);
13680 129 return true;
13681 }
13682 2322 }
13683 else
13684 {
13685
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13686 stunclk=0;
13687 242393 constant_walk_8_old(rate,homing,spw_floater);
13688
13689
13690 242393 misc=dir;
13691
13692 // If any higher-numbered segments were killed, segcnt can be too high,
13693 // leading to a crash
13694
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13695 segcnt=guys.Count()-index-1;
13696
13697
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13698 {
13699 1122281 enemy* segment=((enemy*)guys.spr(i));
13700
13701 // More validation - if segcnt was wrong, this may not
13702 // actually be a Moldorm segment
13703
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13704 {
13705 segcnt=i-index-1;
13706 break;
13707 }
13708
13709
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13710 {
13711 242669 x=segment->x;
13712 242669 y=segment->y;
13713 242669 }
13714
13715 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13716 //Script your own blasted segmented bosses!! -Z
13717 1122281 segment->setParent(this);
13718
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13719 {
13720 217733 segment->dummy_int[1]=2;
13721 217733 }
13722 else
13723 {
13724 904548 segment->dummy_int[1]=1;
13725 }
13726
13727
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13728 {
13729 242669 segment->dummy_int[1]=0;
13730 242669 }
13731
13732
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13733 {
13734 1016 int32_t offset=1;
13735
13736
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13737 {
13738 // Triple-check
13739
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13740 {
13741 segcnt=j-index+1; // Add 1 because of --segcnt below
13742 break;
13743 }
13744 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13745 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13746 1480 }
13747
13748 1016 segment->hclk=33;
13749 1016 --segcnt;
13750 1016 --i; // Recheck the same index in case multiple segments died at once
13751 1016 }
13752 1122281 }
13753
13754
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13755 {
13756 129 clk2=19;
13757
13758 129 x=guys.spr(index+1)->x;
13759 129 y=guys.spr(index+1)->y;
13760 129 }
13761 }
13762
13763 244715 return false;
13764 244844 }
13765
13766 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13767 3150 {
13768
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13769 {
13770
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13771 3150 }
13772
13773
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13774 3150 hyofs=4;
13775 3150 hit_width=hit_height=8;
13776 3150 hxofs=1000;
13777 3150 mainguy=count_enemy=false;
13778 3150 parentclk = 0;
13779 3150 bgsfx=-1;
13780
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13781 //deadsfx = WAV_EDEAD;
13782 3150 isCore = false;
13783 3150 }
13784
13785 1138024 bool esMoldorm::animate(int32_t index)
13786 {
13787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13788 // Shouldn't be possible, but better to be sure
13789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13790 dying=true;
13791
13792
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13793 {
13794
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13795 15743 item_set=0;
13796
13797 15743 return Dead(index);
13798 }
13799
13800
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13801 {
13802 1017204 hxofs=4;
13803 1017204 step=((enemy*)guys.spr(index-1))->step;
13804
13805
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13806 {
13807 70455 misc=dir;
13808 70455 dir=((enemy*)guys.spr(index-1))->misc;
13809 //do alignment, as in parent's animation :-/ -DD
13810 70455 x.doFloor();
13811 70455 y.doFloor();
13812 70455 }
13813
13814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13815 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13816
13817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13818 {
13819 1017204 sprite::move(step);
13820 1017204 }
13821 1017204 }
13822
13823 1122281 return enemy::animate(index);
13824 1138024 }
13825
13826 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13827 {
13828
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13829 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13830
13831 453 return 0;
13832 2683 }
13833
13834 1155313 void esMoldorm::draw(BITMAP *dest)
13835 {
13836 1155313 tile=o_tile;
13837 1155313 int32_t fdiv = frate/4;
13838
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13839
13840
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13841 1155313 efrate:((clk>=(frate>>1))?1:0);
13842
13843
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13844 {
13845 1043930 tile+=dummy_int[1]*40;
13846
13847
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13848 {
13849 102730 flip=0;
13850
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13851
13852
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13853 tile+=4;
13854 102730 }
13855 else
13856 {
13857
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13858 {
13859 case up: //u
13860 96530 flip=0;
13861 96530 break;
13862
13863 case l_up: //d
13864 134534 flip=0;
13865 134534 tile+=4;
13866 134534 break;
13867
13868 case l_down: //l
13869 113426 flip=0;
13870 113426 tile+=8;
13871 113426 break;
13872
13873 case left: //r
13874 124800 flip=0;
13875 124800 tile+=12;
13876 124800 break;
13877
13878 case r_down: //ul
13879 101314 flip=0;
13880 101314 tile+=20;
13881 101314 break;
13882
13883 case down: //ur
13884 99043 flip=0;
13885 99043 tile+=24;
13886 99043 break;
13887
13888 case r_up: //dl
13889 131794 flip=0;
13890 131794 tile+=28;
13891 131794 break;
13892
13893 case right: //dr
13894 139759 flip=0;
13895 139759 tile+=32;
13896 139759 break;
13897 }
13898 }
13899
13900 1043930 tile+=f2;
13901 1043930 }
13902
13903
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13904 1049046 enemy::draw(dest);
13905 1155313 }
13906
13907 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13908 420 {
13909
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13910 {
13911
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13912 420 }
13913 //else { x = X; y = Y; }
13914 //byte legaldirs = 0;
13915 420 int32_t incr = 16;
13916 //int32_t possiiblepos = 0;
13917 //int32_t positions[8] = {0};
13918
13919 //Don't spawn in pits.
13920
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13921 {
13922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13923 {
13924 //move if we spawn over a pit
13925 //check each direction
13926
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13927 {
13928
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13929 }
13930
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13931 {
13932
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13933 }
13934
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13935 {
13936
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13937 }
13938
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13939 {
13940
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13941 }
13942
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13943 {
13944 y -= incr; break;
13945 }
13946
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13947 {
13948 y+=incr; break;
13949 }
13950
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13951 {
13952
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13953 }
13954
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13955 {
13956 x+=incr; y+=incr; break;
13957 }
13958 34 else continue;
13959
13960 }
13961
13962 105 }
13963
13964 420 dir=up;
13965 420 superman=1;
13966 420 fading=fade_invisible;
13967 420 hxofs=1000;
13968 420 segcnt=clk;
13969 420 clk=0;
13970 //set up move history
13971
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13972
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13973 420 }
13974
13975 236907 bool eLanmola::animate(int32_t index)
13976 {
13977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13978
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13979 {
13980 40196 removearmos(x,y);
13981 40196 }
13982
13983
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
13984 {
13985
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
13986 {
13987
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
13988 86 leave_item();
13989
13990 189 stop_bgsfx(index);
13991 189 return true;
13992 }
13993
13994 3402 return false;
13995 }
13996
13997
13998 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
13999 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14000 //I've added a complete movement history to this enemy to compensate -DD
14001 233316 constant_walk(rate,homing,spw_none);
14002 233316 prevState.pop_front();
14003 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14004
14005 // This could cause a crash with Moldorms. I didn't see the same problem
14006 // with Lanmolas, but it looks like it ought to be possible, so here's
14007 // the same solution. - Saf
14008
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14009 segcnt=guys.Count()-index-1;
14010
14011
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14012 {
14013 966396 enemy* segment=((enemy*)guys.spr(i));
14014
14015 // More validation in case segcnt is wrong
14016
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14017 {
14018 segcnt=i-index-1;
14019 break;
14020 }
14021
14022 966396 segment->o_tile=o_tile;
14023 966396 segment->setParent(this);
14024
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14025 {
14026 195700 segment->dummy_int[1]=1; //tail
14027 195700 }
14028 else
14029 {
14030 770696 segment->dummy_int[1]=0;
14031 }
14032
14033
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14034 {
14035
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14036 {
14037 // Triple-check
14038
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14039 {
14040 segcnt=j-index+1; // Add 1 because of --segcnt below
14041 break;
14042 }
14043 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14044 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14045 1961 }
14046
14047 1169 ((enemy*)guys.spr(i))->hclk=33;
14048 1169 --segcnt;
14049 1169 --i; // Recheck the same index in case multiple segments died at once
14050 1169 }
14051 966396 }
14052
14053
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14054 {
14055 189 clk2=19;
14056 189 x=guys.spr(index+1)->x;
14057 189 y=guys.spr(index+1)->y;
14058 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14059 189 }
14060
14061 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14062 //which is... disastrous.
14063 233316 hp = 1;
14064 233316 return enemy::animate(index);
14065 236907 }
14066
14067 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14068 2267 {
14069
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14070 {
14071
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14072 2267 }
14073 2267 int32_t incr = 16;
14074 //Don't spawn in pits.
14075
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14076 {
14077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14078 {
14079 //move if we spawn over a pit
14080 //check each direction
14081
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14082 {
14083
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14084 }
14085
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14086 {
14087
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14088 }
14089
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14090 {
14091
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14092 }
14093
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14094 {
14095
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14096 }
14097
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14098 {
14099 y -= incr; break;
14100 }
14101
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14102 {
14103 y+=incr; break;
14104 }
14105
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14106 {
14107
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14108 }
14109
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14110 {
14111 x+=incr; y+=incr; break;
14112 }
14113 170 else continue;
14114
14115 }
14116
14117 525 }
14118
14119 2267 hxofs=1000;
14120 2267 hit_width=8;
14121 2267 mainguy=false;
14122 2267 count_enemy=(id<0x2000)?true:false;
14123
14124 //set up move history
14125
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14126
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14127
14128 2267 bgsfx = -1;
14129 2267 isCore = false;
14130
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14131 2267 }
14132
14133 985563 bool esLanmola::animate(int32_t index)
14134 {
14135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14136 // Shouldn't be possible, but who knows
14137
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14138 18 dying=true;
14139
14140
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14141 {
14142 19167 xofs=0;
14143
14144
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14145 9306 item_set=0;
14146
14147 19167 return Dead(index);
14148 }
14149
14150
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14151 {
14152 930450 hxofs=4;
14153
14154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14155 {
14156 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14157 930450 prevState.pop_front();
14158 930450 prevState.push_back(newstate);
14159 930450 x = newstate.first.first;
14160 930450 y = newstate.first.second;
14161 930450 dir = newstate.second;
14162 930450 }
14163 930450 }
14164
14165 966396 return enemy::animate(index);
14166 985563 }
14167
14168 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14169 {
14170
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14171 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14172
14173 590 return 0;
14174 2655 }
14175
14176 990931 void esLanmola::draw(BITMAP *dest)
14177 {
14178 990931 tile=o_tile;
14179 990931 int32_t fdiv = frate/4;
14180
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14181
14182
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14183 990931 efrate:((clk>=(frate>>1))?1:0);
14184
14185
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14186 {
14187
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14188 {
14189 481767 tile+=20;
14190
14191
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14192 {
14193 128742 tile+=20;
14194 128742 }
14195 481767 }
14196
14197
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14198 {
14199 case up:
14200 141419 flip=0;
14201 141419 break;
14202
14203 case down:
14204 140994 flip=0;
14205 140994 tile+=4;
14206 140994 break;
14207
14208 case left:
14209 159500 flip=0;
14210 159500 tile+=8;
14211 159500 break;
14212
14213 case right:
14214 187019 flip=0;
14215 187019 tile+=12;
14216 187019 break;
14217 }
14218
14219 628932 tile+=f2;
14220 628932 }
14221 else
14222 {
14223
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14224 {
14225 271456 tile+=1;
14226 271456 }
14227 }
14228
14229
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14230 953893 enemy::draw(dest);
14231 990931 }
14232
14233 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14234 150 {
14235 //these are here to bypass compiler warnings about unused arguments
14236 150 Clk=Clk;
14237 150 superman=1;
14238
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14239 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14240
14241
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14242 692 arm[i]=i;
14243
14244 150 fading=fade_blue_poof;
14245 //nets+4680;
14246 150 adjusted=false;
14247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14248 150 }
14249
14250 66494 bool eManhandla::animate(int32_t index)
14251 {
14252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14253
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14254 1382 return Dead(index);
14255
14256
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14257 {
14258 2471 removearmos(x,y);
14259 2471 }
14260
14261
14262 // check arm status, move dead ones to end of group
14263
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14264 {
14265 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14266
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14267 {
14268
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14269 {
14270 552 zc_swap(arm[j],arm[j+1]);
14271 552 guys.swap(index+j+1,index+j+2);
14272 552 }
14273
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14274 {
14275 87 leave_item();
14276 87 }
14277 424 --armcnt;
14278 424 --i;
14279 424 continue;
14280 }
14281
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14282 {
14283
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14284 {
14285 508 cur_arm->o_tile=o_tile+40;
14286 508 cur_arm->setParent(this);
14287 508 }
14288 else
14289 {
14290 184 cur_arm->o_tile=o_tile+160;
14291 184 cur_arm->setParent(this);
14292 }
14293 692 }
14294 193194 }
14295
14296 65112 adjusted=true;
14297
14298 // move or die
14299
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14300 83 hp=0;
14301 else
14302 {
14303 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14304
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14305
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14306 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14307
14308
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14309 {
14310
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14311 {
14312
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14313 {
14314 case 0:
14315 38579 dy1=-24;
14316 38579 break;
14317
14318 case 1:
14319 36328 dy2=31;
14320 36328 break;
14321
14322 case 2:
14323 36250 dx1=-16;
14324 36250 break;
14325
14326 case 3:
14327 39862 dx2=31;
14328 39862 break;
14329 }
14330 151019 }
14331 53584 }
14332 else
14333 {
14334 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14335
14336
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14337 {
14338
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14339 {
14340 case 0:
14341 12012 dy1=-32;
14342 12012 break;
14343
14344 case 1:
14345 7730 dy2=39;
14346 7730 break;
14347
14348 case 2:
14349 9837 dx1=-24;
14350 9837 break;
14351
14352 case 3:
14353 12596 dx2=39;
14354 12596 break;
14355 }
14356 42175 }
14357 }
14358
14359 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14360
14361
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14362 {
14363 193194 zfix dx=(zfix)0,dy=(zfix)0;
14364
14365
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14366 {
14367
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14368 {
14369 case 0:
14370 38579 dy=-16;
14371 38579 break;
14372
14373 case 1:
14374 36328 dy=16;
14375 36328 break;
14376
14377 case 2:
14378 36250 dx=-16;
14379 36250 break;
14380
14381 case 3:
14382 39862 dx=16;
14383 39862 break;
14384 }
14385 151019 }
14386 else
14387 {
14388
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14389 {
14390 case 0:
14391 5447 dy=-24;
14392 5447 dx=-8;
14393 5447 break;
14394
14395 case 1:
14396 3986 dy=24;
14397 3986 dx=8;
14398 3986 break;
14399
14400 case 2:
14401 4163 dx=-24;
14402 4163 dy=8;
14403 4163 break;
14404
14405 case 3:
14406 6774 dx=24;
14407 6774 dy=-8;
14408 6774 break;
14409
14410 case 4:
14411 6565 dy=-24;
14412 6565 dx=8;
14413 6565 break;
14414
14415 case 5:
14416 3744 dy=24;
14417 3744 dx=-8;
14418 3744 break;
14419
14420 case 6:
14421 5674 dx=-24;
14422 5674 dy=-8;
14423 5674 break;
14424
14425 case 7:
14426 5822 dx=24;
14427 5822 dy=8;
14428 5822 break;
14429 }
14430 }
14431
14432 193194 guys.spr(index+i+1)->x = x+dx;
14433 193194 guys.spr(index+i+1)->y = y+dy;
14434 193194 }
14435 }
14436
14437 65112 return enemy::animate(index);
14438 66494 }
14439
14440
14441 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14442 {
14443 1751 int32_t wpnId = w->id;
14444
14445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14446 return 0;
14447
14448
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14449 {
14450 case wBomb:
14451 case wSBomb:
14452 case wSword:
14453 case wHammer:
14454 case wWand:
14455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14456
14457 case wLitBomb:
14458 case wLitSBomb:
14459 case wBait:
14460 case wWhistle:
14461 case wFire:
14462 case wWind:
14463 case wSSparkle:
14464 case wFSparkle:
14465 case wPhantom:
14466 1709 return 0;
14467
14468 case wHookshot:
14469 case wBrang:
14470 sfx(WAV_CHINK,pan(x));
14471 break;
14472
14473 default:
14474
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14475 else sfx(WAV_CHINK,pan(x));
14476
14477 42 }
14478
14479 42 return 1;
14480 1751 }
14481
14482 66490 void eManhandla::draw(BITMAP *dest)
14483 {
14484 66490 tile=o_tile;
14485 66490 int32_t fdiv = frate/4;
14486
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14487
14488
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14489 66490 efrate:((clk>=(frate>>1))?1:0);
14490
14491
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14492 {
14493
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14494 {
14495
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14496 {
14497 case up: //u
14498 4771 flip=0;
14499 4771 break;
14500
14501 case l_up: //d
14502 4640 flip=0;
14503 4640 tile+=4;
14504 4640 break;
14505
14506 case l_down: //l
14507 4995 flip=0;
14508 4995 tile+=8;
14509 4995 break;
14510
14511 case left: //r
14512 5574 flip=0;
14513 5574 tile+=12;
14514 5574 break;
14515
14516 case r_down: //ul
14517 3793 flip=0;
14518 3793 tile+=20;
14519 3793 break;
14520
14521 case down: //ur
14522 3930 flip=0;
14523 3930 tile+=24;
14524 3930 break;
14525
14526 case r_up: //dl
14527 3908 flip=0;
14528 3908 tile+=28;
14529 3908 break;
14530
14531 case right: //dr
14532 5883 flip=0;
14533 5883 tile+=32;
14534 5883 break;
14535 }
14536
14537 37494 tile+=f2;
14538 37494 enemy::draw(dest);
14539 37494 } //manhandla 2, big body
14540 else
14541 {
14542
14543
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14544 {
14545 case up: //u
14546 1277 flip=0;
14547 1277 break;
14548
14549 case l_up: //d
14550 1360 flip=0;
14551 1360 tile+=8;
14552 1360 break;
14553
14554 case l_down: //l
14555 2242 flip=0;
14556 2242 tile+=40;
14557 2242 break;
14558
14559 case left: //r
14560 1789 flip=0;
14561 1789 tile+=48;
14562 1789 break;
14563
14564 case r_down: //ul
14565 1345 flip=0;
14566 1345 tile+=80;
14567 1345 break;
14568
14569 case down: //ur
14570 805 flip=0;
14571 805 tile+=88;
14572 805 break;
14573
14574 case r_up: //dl
14575 948 flip=0;
14576 948 tile+=120;
14577 948 break;
14578
14579 case right: //dr
14580 1542 flip=0;
14581 1542 tile+=128;
14582 1542 break;
14583 }
14584
14585 11308 tile+=(f2*2);
14586 11308 xofs-=8;
14587 11308 yofs-=8;
14588 11308 drawblock(dest,15);
14589 11308 xofs+=8;
14590 11308 yofs+=8;
14591 }
14592 48802 }
14593 else
14594 {
14595
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14596 {
14597 17173 enemy::draw(dest);
14598 17173 }
14599 else
14600 {
14601 515 xofs-=8;
14602 515 yofs-=8;
14603 515 enemy::draw(dest);
14604 515 xofs+=16;
14605 515 enemy::draw(dest);
14606 515 yofs+=16;
14607 515 enemy::draw(dest);
14608 515 xofs-=16;
14609 515 enemy::draw(dest);
14610 515 xofs+=8;
14611 515 yofs-=8;
14612 }
14613 }
14614 66490 }
14615
14616 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14617 692 {
14618 692 id=misc=clk;
14619 692 dir = clk & 3;
14620 692 clk=0;
14621 692 mainguy=count_enemy=false;
14622 692 dummy_bool[0]=false;
14623 692 item_set=0;
14624 692 bgsfx=-1;
14625 692 deadsfx = WAV_EDEAD;
14626
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14627 692 isCore = false;
14628
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14629 692 }
14630
14631 200202 bool esManhandla::animate(int32_t index)
14632 {
14633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14634
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14635 7008 return Dead(index);
14636
14637
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14638 {
14639 12404 removearmos(x,y);
14640 12404 }
14641
14642
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14643 {
14644 27896 clk2=unsigned(zc_oldrand())%5+5;
14645 27896 clk3^=1;
14646 27896 }
14647
14648
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14649 {
14650 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14651 1491 sfx(wpnsfx(wpn),pan(x));
14652 1491 }
14653
14654 193194 return enemy::animate(index);
14655 200202 }
14656
14657 200186 void esManhandla::draw(BITMAP *dest)
14658 {
14659 200186 tile=o_tile;
14660 200186 int32_t fdiv = frate/4;
14661
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14662
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14663 200186 efrate:((clk>=(frate>>1))?1:0);
14664
14665
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14666 {
14667
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14668 {
14669 case up:
14670 39945 break;
14671
14672 case down:
14673 36845 tile+=4;
14674 36845 break;
14675
14676 case left:
14677 39966 tile+=8;
14678 39966 break;
14679
14680 case right:
14681 41960 tile+=12;
14682 41960 break;
14683 }
14684
14685 158716 tile+=f2;
14686 158716 }
14687 else
14688 {
14689
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14690 {
14691 case down:
14692 8961 flip=2;
14693
14694 [[fallthrough]];
14695 case up:
14696 21355 tile=(clk3)?188:189;
14697 21355 break;
14698
14699 case right:
14700 12232 flip=1;
14701 [[fallthrough]];
14702
14703 case left:
14704 20115 tile=(clk3)?186:187;
14705 20115 break;
14706 }
14707 }
14708
14709 200186 enemy::draw(dest);
14710 200186 }
14711
14712 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14713 168 {
14714
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14715 {
14716
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14717 168 }
14718 else
14719 {
14720 if ( !(editorflags & ENEMY_FLAG6) )
14721 {
14722 x = X; y = Y;
14723 }
14724 else
14725 {
14726 x = X+8; y = Y;
14727 }
14728 }
14729 168 hzsz = 32; // can't be jumped.
14730 168 flameclk=0;
14731 168 misc=clk; // total head count
14732 168 clk3=clk; // live head count
14733 168 clk=0;
14734 168 clk2=60; // fire ball clock
14735 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14736
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14737 168 dir = down;
14738 168 hxofs=4;
14739 168 hit_width=8;
14740 // frate=17*4;
14741 168 fading=fade_blue_poof;
14742 //nets+5420;
14743
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14744 {
14745 /*
14746 necktile=o_tile+8;
14747 if (dmisc3)
14748 {
14749 necktile+=8;
14750 }
14751 */
14752 133 necktile=o_tile+dmisc6;
14753 133 }
14754 else
14755 {
14756 35 necktile=s_tile;
14757 }
14758 168 }
14759
14760 155290 bool eGleeok::animate(int32_t index)
14761 {
14762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14763
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14764 2199 return Dead(index);
14765
14766
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14767 {
14768 684 removearmos(x,y);
14769 684 }
14770
14771 // Check if a head was killed somehow...
14772
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14773 51372 clk3=guys.Count()-index-1;
14774
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14775 87041 misc=guys.Count()-index-1;
14776
14777 //fix for the "kill all enemies" item
14778
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14779 {
14780
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14781 {
14782 // I haven't seen this fail, but it seems like it ought to be
14783 // possible, so I'm checking for it. - Saf
14784
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14785 break;
14786 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14787 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14788 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14789 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14790 12 }
14791
14792 6 clk3=0;
14793
14794
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14795 {
14796
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14797 break;
14798 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14799 12 }
14800 6 }
14801
14802
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14803 {
14804 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14805 403171 head->dummy_int[1]=necktile;
14806 403171 head->setParent(this);
14807
14808
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14809 {
14810 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14811 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14812 320127 }
14813 else
14814 {
14815 83044 head->dummy_int[2]=necktile+1; //connected head tile
14816 83044 head->dummy_int[3]=necktile+2; //flying head tile
14817 }
14818
14819 403171 head->dmisc5=dmisc5; //neck segments
14820
14821 /*
14822 if (dmisc3)
14823 {
14824 head->dummy_bool[0]=true;
14825 }
14826 */
14827
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14828 {
14829
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14830 {
14831 1228 hp -= 1000 - head->hp;
14832 1228 hclk = 33;
14833
14834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14835
14836 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14837 1228 }
14838
14839 5655 head->hclk = 0;
14840 5655 }
14841
14842 // Must be set in case of naughty ZScripts
14843 403171 head->hp = 1000;
14844 403171 }
14845
14846
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14847 {
14848 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14849 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14850 415 }
14851
14852
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14853 {
14854
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14855 {
14856 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14857 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14858 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14859 1287 sfx(wpnsfx(wpn),pan(x));
14860 1287 clk2=0;
14861 1287 }
14862 95682 }
14863 else
14864 {
14865
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14866 {
14867 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14868 557 head->timer=zc_oldrand()%50+50;
14869 557 clk2=0;
14870 557 }
14871 }
14872
14873
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14874 {
14875
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14876 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14877
14878
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14879 127 }
14880
14881 153091 return enemy::animate(index);
14882 155290 }
14883
14884 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14885 {
14886 1239 return 0;
14887 }
14888
14889 156918 void eGleeok::draw(BITMAP *dest)
14890 {
14891 156918 tile=o_tile;
14892
14893
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14894 {
14895 2199 enemy::draw(dest);
14896 2199 return;
14897 }
14898
14899 154719 int32_t f=clk/17;
14900
14901
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14902 {
14903 // body
14904 120524 xofs=-8;
14905 120524 yofs=32;
14906
14907
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14908
14909 {
14910 case 0:
14911 9155 tile+=0;
14912 9155 break;
14913
14914 case 1:
14915 10095 tile+=2;
14916 10095 break;
14917
14918 case 2:
14919 8686 tile+=4;
14920 8686 break;
14921
14922 default:
14923 92588 tile+=6;
14924 92588 break;
14925 }
14926 120524 }
14927 else
14928 {
14929 // body
14930 34195 xofs=-8;
14931 34195 yofs=32;
14932
14933
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14934 {
14935 case 0:
14936 2514 tile+=0;
14937 2514 break;
14938
14939 case 2:
14940 2459 tile+=4;
14941 2459 break;
14942
14943 default:
14944 29222 tile+=2;
14945 29222 break;
14946 }
14947 }
14948
14949 154719 enemy::drawblock(dest,15);
14950 156918 }
14951
14952 156918 void eGleeok::draw2(BITMAP *dest)
14953 {
14954 // the neck stub
14955 156918 tile=necktile;
14956 156918 xofs=0;
14957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14958
14959
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14960 {
14961 122181 tile+=((clk&24)>>3);
14962 122181 }
14963
14964
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14965 {
14966 154719 mapscr* scr = get_scr(screen_spawned);
14967
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14968 737 sprite::drawcloaked(dest);
14969 else
14970 153982 sprite::draw(dest);
14971 154719 }
14972 156918 }
14973
14974
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14975 533 {
14976
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14977
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14978
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14979 // dummy_bool[0]=false;
14980 533 timer=0;
14981 /* fixing */
14982 533 hp=1000;
14983
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
14984 533 item_set=0;
14985
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
14986
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
14987 533 hxofs=4;
14988 533 hit_width=8;
14989
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14990 533 clk2=clk; // how int32_t to wait before moving first time
14991 533 clk=0;
14992 533 mainguy=count_enemy=false;
14993
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
14994 533 clk3=((dir&2)>>1)+2; // left or right
14995 533 dir&=1; // up or down
14996
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
14997 533 isCore = false;
14998
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
14999
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15000 {
15001 2132 nxoffset[i] = 0;
15002 2132 nyoffset[i] = 0;
15003
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15004
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15005 2132 }
15006
15007 533 necktile=0;
15008 //TODO compatibility? -DD
15009 /*
15010 for(int32_t i=0; i<4; i++)
15011 {
15012 nx[i]=124;
15013 ny[i]=i*6+48;
15014 }*/
15015 533 bgsfx=-1;
15016 //no need for deadsfx
15017 533 }
15018
15019 515535 bool esGleeok::animate(int32_t index)
15020 {
15021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15022 // don't call removearmos() - it's a segment.
15023
15024 515535 dmisc5=vbound(dmisc5,1,255);
15025
15026
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15027 {
15028 402762 x = (xoffset+parent->x);
15029 402762 y = (yoffset+parent->y);
15030
15031
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15032 {
15033 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15034 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15035 1611048 }
15036 402762 }
15037
15038 // set up the head tiles
15039 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15040 /*
15041 if (dummy_bool[0]) //if this is a flame gleeok
15042 {
15043 headtile+=180;
15044 }
15045 */
15046 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15047 515535 flyingheadtile=dummy_int[3];
15048
15049 // set up the neck tiles
15050 515535 necktile=dummy_int[1];
15051
15052
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15053 {
15054 402833 necktile+=((clk&24)>>3);
15055 402833 }
15056
15057 /*
15058 else
15059 {
15060 necktile=145;
15061 }
15062 */
15063 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15064
15065
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15066 {
15067 case 0: // live head
15068 // set up the attached head tiles
15069 402762 tile=headtile;
15070
15071
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15072 {
15073 319820 tile+=((clk&24)>>3);
15074 /*
15075 if (dummy_bool[0]) {
15076 tile+=1561;
15077 }
15078 */
15079 319820 }
15080
15081 /*
15082 else
15083 {
15084 tile=146;
15085 }
15086 */
15087
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15088 {
15089
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15090
15091
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15092
15093
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15094 {
15095 292 dir^=1;
15096 292 }
15097
15098 92832 zfix tempx = x;
15099 92832 zfix tempy = y;
15100
15101 92832 sprite::move(step);
15102 92832 xoffset += (x-tempx);
15103 92832 yoffset += (y-tempy);
15104
15105
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15106 {
15107 3863 clk3^=1;
15108 3863 clk2=-4;
15109 3863 }
15110 else
15111 {
15112
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15113 {
15114 978 clk3=right;
15115 978 }
15116
15117
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15118 {
15119 961 clk3=left;
15120 961 }
15121
15122
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15123 {
15124 3713 clk3^=1; // x jig
15125 3713 }
15126 else
15127 {
15128
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15129 {
15130 851 clk3^=1; // x switch back
15131 851 }
15132
15133 85256 clk2=-4;
15134 }
15135 }
15136
15137 92832 zc_swap(dir,clk3);
15138 92832 tempx = x;
15139 92832 tempy = y;
15140 92832 sprite::move(step);
15141 92832 xoffset += (x-tempx);
15142 92832 yoffset += (y-tempy);
15143 92832 zc_swap(dir,clk3);
15144
15145
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15146 {
15147 278496 nxoffset[i] = (zc_oldrand()%3);
15148 278496 nyoffset[i] = (zc_oldrand()%3);
15149 278496 }
15150 92832 }
15151
15152 402762 break;
15153
15154 case 1: // flying head
15155
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15156
15157 {
15158 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15159 105482 }
15160
15161 112071 break;
15162
15163 // the following are messages sent from the main guy...
15164 case -1: // got chopped off
15165 {
15166 300 misc=1;
15167 300 superman=1;
15168 300 hxofs=xofs=0;
15169 300 hit_width=16;
15170 300 cs=8;
15171 300 clk=-24;
15172 300 clk2=40;
15173 300 dir=(zc_oldrand()&7)+8;
15174 300 step=8.0/9.0;
15175 }
15176 300 break;
15177
15178 case -2: // the big guy is dead
15179 402 return true;
15180 }
15181
15182
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15183 {
15184
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15185 {
15186 4791 FireBreath(true);
15187 4791 }
15188
15189 40125 --timer;
15190 40125 }
15191
15192 515133 return enemy::animate(index);
15193 515535 }
15194
15195 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15196 {
15197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15198 {
15199 int32_t wpnId = w->id;
15200
15201 if(dying)
15202 return 0;
15203
15204 switch(wpnId)
15205 {
15206 case wLitBomb:
15207 case wLitSBomb:
15208 case wBait:
15209 case wWhistle:
15210 case wFire:
15211 case wWind:
15212 case wSSparkle:
15213 case wFSparkle:
15214 case wPhantom:
15215 return 0;
15216
15217 case wHookshot:
15218 case wBrang:
15219 case wBeam:
15220 case wArrow:
15221 case wMagic:
15222 case wBomb:
15223 case wSBomb:
15224 sfx(WAV_CHINK,pan(x));
15225 break;
15226 default:
15227 break;
15228 }
15229
15230 return 1;
15231 }
15232 else
15233 {
15234 7080 int32_t ret = enemy::takehit(w,realweap);
15235
15236
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15237 5655 return -2; // force it to wait a frame before checking sword attacks again
15238
15239 1425 return ret;
15240 }
15241 7080 }
15242
15243 521456 void esGleeok::draw(BITMAP *dest)
15244 {
15245 521456 dmisc5=vbound(dmisc5,1,255);
15246
15247
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15248 {
15249 case 0: //neck
15250
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15251 {
15252
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15253 {
15254 1227318 mapscr* scr = get_scr(screen_spawned);
15255
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15256 {
15257
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15258 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15259 else
15260 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15261 978198 }
15262 else
15263 {
15264
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15265 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15266 else
15267 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15268 }
15269 1227318 }
15270 409106 }
15271
15272 409106 break;
15273
15274 case 1: //flying head
15275 112350 tile=flyingheadtile;
15276
15277
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15278 {
15279 82692 tile+=((clk&24)>>3);
15280 82692 break;
15281 }
15282 29658 }
15283 521456 }
15284
15285 521456 void esGleeok::draw2(BITMAP *dest)
15286 {
15287 521456 enemy::draw(dest);
15288 521456 }
15289
15290 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15291 190 {
15292
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15293 {
15294
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15295
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15296 190 }
15297 else { x = X; y = Y; }
15298 190 adjusted=false;
15299
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15300 //step=0.25;
15301 190 flycnt=dmisc1;
15302 190 flycnt2=dmisc2;
15303 190 loopcnt=0;
15304 190 clk4 = 0;
15305 190 clk5 = 0;
15306 190 clk6 = 0;
15307 190 clk7 = 0;
15308
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15310 {
15311
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15312 {
15313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15314 105 else dmisc29 = (84 / 3);
15315 105 }
15316 else
15317 {
15318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15319 85 else dmisc29 = (84 / 2);
15320 }
15321 190 }
15322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15323 {
15324
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15327 105 else dmisc30 = (84 / 3)*0.5;
15328 105 }
15329 else
15330 {
15331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15332 85 else dmisc30 = (84 / 2)*0.5;
15333 }
15334 190 }
15335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15336 {
15337
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15338 {
15339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15340 105 else dmisc31 = (84 / 3)*2;
15341 105 }
15342 else
15343 {
15344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15345 85 else dmisc31 = (84 / 2)*0.5;
15346 }
15347 190 }
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15349 {
15350
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15351 {
15352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15353 105 else dmisc32 = (84 / 3);
15354 105 }
15355 else
15356 {
15357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15358 85 else dmisc32 = (84 / 2)*0.25;
15359 }
15360 190 }
15361
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15362 190 }
15363
15364 161885 bool ePatra::animate(int32_t index)
15365 {
15366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15367
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15368 {
15369
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15370 {
15371 72 auto segment = (enemy*)guys.spr(i);
15372
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15373 72 segment->hp = -1000;
15374 72 }
15375
15376 1444 return Dead(index);
15377 }
15378
15379 160441 double basesize = 84;
15380
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15381 160441 double halfsize = basesize / 2;
15382 160441 double quartersize = halfsize / 2;
15383 160441 double twothirdsize = (basesize / 3)*2;
15384 160441 double onethirdsize = (basesize / 3);
15385
15386
15387
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15388 {
15389 36934 removearmos(x,y);
15390 36934 }
15391
15392
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15393 {
15394
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15395
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15396
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15397 {
15398 1797 clk2=0;
15399
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15400 {
15401
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15402 932 --loopcnt;
15403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15404 {
15405
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15406 {
15407
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15408 356 else loopcnt=dmisc7;
15409 356 }
15410 865 }
15411 else if (loopcnt == -1) loopcnt=dmisc7;
15412 else ++loopcnt;
15413
15414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15415 1797 }
15416 else
15417 {
15418 loopcnt = 0;
15419 misc = 1;
15420 }
15421 1797 }
15422 160441 }
15423
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15424
15425
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15426 {
15427 if (dmisc5 == 1 || dmisc5 == 3)
15428 {
15429 if (get_qr(qr_NEWENEMYTILES))
15430 {
15431 if (clk7 <= 0 || clk6 != -16) ++clk6;
15432 if (clk6 == 0) o_tile=d->e_tile;
15433 else
15434 {
15435 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15436 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15437 }
15438 }
15439 else clk6 = 0;
15440 }
15441 }
15442
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15443
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15444
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15445
15446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15447
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15448
15449
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15450 {
15451 //outside ring
15452
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15453 {
15454
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15455 {
15456 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15457 1152 enemy *s = ((enemy*)guys.spr(i));
15458 1152 s->setParent(this);
15459 1152 }
15460 else
15461 {
15462 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15463 192 enemy *s = ((enemy*)guys.spr(i));
15464 192 s->setParent(this);
15465 }
15466
15467 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15468 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15469 1344 }
15470
15471
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15472 {
15473
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15474 {
15475 2889 guys.swap(j,j+1);
15476 2889 }
15477
15478
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15479 764 }
15480 else
15481 {
15482 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15483
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15484
15485
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15486 {
15487 //maybe playing_field_offset here?
15488
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15489 {
15490
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15491
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15492 237330 }
15493 else
15494 {
15495 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15496 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15497 }
15498
15499 447583 temp_x=guys.spr(i)->x;
15500 447583 temp_y=guys.spr(i)->y;
15501 447583 }
15502 else //Oval
15503 {
15504 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15505 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15506
15507
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15508 {
15509 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15510
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15511 121041 }
15512 else
15513 {
15514 90996 guys.spr(i)->x = circle_x;
15515 90996 guys.spr(i)->y = circle_y;
15516 }
15517
15518 212037 temp_x=circle_x;
15519 212037 temp_y=circle_y;
15520 }
15521
15522 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15523 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15524
15525
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15526 {
15527 83117 guys.spr(i)->dir=l_down;
15528 83117 }
15529
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15530 {
15531 83568 guys.spr(i)->dir=left;
15532 83568 }
15533
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15534 {
15535 82454 guys.spr(i)->dir=l_up;
15536 82454 }
15537
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15538 {
15539 82188 guys.spr(i)->dir=up;
15540 82188 }
15541
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15542 {
15543 81600 guys.spr(i)->dir=r_up;
15544 81600 }
15545
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15546 {
15547 81993 guys.spr(i)->dir=right;
15548 81993 }
15549
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15550 {
15551 81699 guys.spr(i)->dir=r_down;
15552 81699 }
15553 else
15554 {
15555 83001 guys.spr(i)->dir=down;
15556 }
15557
15558 659620 guys.spr(i)->x += x;
15559 659620 guys.spr(i)->y += y;
15560 }
15561 660384 }
15562
15563
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15564 {
15565 32331 int timeneeded = 48;
15566 32331 int patbreath = (zc_oldrand()%50+50);
15567
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15568
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15569 {
15570 timeneeded = 48 + patbreath;
15571 }
15572
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15573 {
15574 timeneeded = 48 + 96;
15575 }
15576
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15577
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15578
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15579 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15580 249 && (clk6 >= 0) //if not in the middle of firing...
15581 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15582
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15583 {
15584
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15585 {
15586 case patratSTREAM:
15587 {
15588 clk7 = 97;
15589 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15590 else clk6 = 0;
15591 break;
15592 }
15593 case patratBREATH:
15594 {
15595 clk7 = patbreath;
15596 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15597 else clk6 = 0;
15598 break;
15599 }
15600 default:
15601 {
15602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15603 {
15604 clk6 = -48;
15605 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15606 }
15607 else
15608 {
15609 249 clk6 = 0;
15610
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15611 249 FirePatraWeapon();
15612 }
15613 249 break;
15614 }
15615 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15616 249 }
15617
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15618 {
15619 switch(dmisc28)
15620 {
15621 case patratSTREAM:
15622 {
15623 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15624 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15625 break;
15626 }
15627 case patratBREATH:
15628 {
15629 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15630 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15631 break;
15632 }
15633 default:
15634 {
15635 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15636 {
15637 FirePatraWeapon();
15638 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15639 }
15640 break;
15641 }
15642 }
15643 }
15644 32331 }
15645
15646 160441 int randattempts = 0;
15647 160441 int randeye = 0;
15648
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15649 {
15650 46240 do
15651 {
15652
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15653 46240 randeye += (index + flycnt + 1);
15654 46240 ++randattempts;
15655
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15656 46240 }
15657 160441 bool dofire = false;
15658
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15659 {
15660 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15661 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15662 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15663 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15664 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15665 {
15666 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15667 {
15668 if (clk5 >= dmisc19)
15669 {
15670 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15671 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15672 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15673 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15674 || dmisc18 == -1)
15675 dofire = true;
15676 }
15677 }
15678 }
15679 }
15680
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15681 {
15682
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15683 {
15684
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15685 {
15686 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15687
15688
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15689 {
15690
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15691 {
15692
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15693 {
15694 // Center eye shoots projectiles; make room for its firing tiles
15695 case 1:
15696 case 3:
15697 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15698 144 break;
15699
15700 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15701 default:
15702 case 2:
15703 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15704 168 break;
15705 }
15706 312 }
15707 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15708 312 }
15709 else
15710 {
15711 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15712 }
15713
15714 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15715
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15716 312 }
15717
15718
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15719 {
15720 263816 ((enemy*)guys.spr(i))->superman=true;
15721 263816 }
15722 else
15723 {
15724 70613 ((enemy*)guys.spr(i))->superman=false;
15725 }
15726
15727
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15728 {
15729
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15730 {
15731 269 guys.swap(j,j+1);
15732 269 }
15733
15734
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15735 145 }
15736 else
15737 {
15738 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15739
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15740
15741
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15742 {
15743
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15744 {
15745
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15746
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15747 168378 }
15748 else
15749 {
15750 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15751 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15752 }
15753
15754 327025 temp_x=guys.spr(i)->x;
15755 327025 temp_y=guys.spr(i)->y;
15756 327025 }
15757 else
15758 {
15759 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15760 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15761
15762
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15763 {
15764 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15765
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15766 3965 }
15767 else
15768 {
15769 3294 guys.spr(i)->x = circle_x;
15770 3294 guys.spr(i)->y = circle_y;
15771 }
15772
15773 7259 temp_x=circle_x;
15774 7259 temp_y=circle_y;
15775 }
15776
15777 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15778 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15779
15780
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15781 {
15782 41746 guys.spr(i)->dir=l_down;
15783 41746 }
15784
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15785 {
15786 41734 guys.spr(i)->dir=left;
15787 41734 }
15788
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15789 {
15790 41742 guys.spr(i)->dir=l_up;
15791 41742 }
15792
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15793 {
15794 41758 guys.spr(i)->dir=up;
15795 41758 }
15796
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15797 {
15798 41830 guys.spr(i)->dir=r_up;
15799 41830 }
15800
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15801 {
15802 41824 guys.spr(i)->dir=right;
15803 41824 }
15804
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15805 {
15806 41852 guys.spr(i)->dir=r_down;
15807 41852 }
15808 else
15809 {
15810 41798 guys.spr(i)->dir=down;
15811 }
15812
15813 334284 guys.spr(i)->x += x;
15814 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15815
15816
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15817 {
15818 /*
15819 if(!(zc_oldrand()&127))
15820 {
15821 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15822 sfx(wpnsfx(wpn),pan(x));
15823 }
15824 */
15825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15826 {
15827 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15828 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15829 {
15830 if (dmisc5 == 3)
15831 {
15832 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15833 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15834 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15835 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15836 }
15837 else
15838 {
15839 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15840 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15841 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15842 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15843 }
15844 }
15845 else
15846 {
15847 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15848 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15849 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15850 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15851 }
15852 }
15853
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15854
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15855
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15856 {
15857
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15858 {
15859 case 4: //Single one rapidfires
15860 {
15861 if (dofire && i == randeye)
15862 {
15863 ((esPatra*)guys.spr(i))->clk5 = -16;
15864 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15865 ((esPatra*)guys.spr(i))->clk4 = 96;
15866 clk5 = -3;
15867 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15868 }
15869 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15870 {
15871 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15872 sfx(wpnsfx(wpn),pan(x));
15873 }
15874 break;
15875 }
15876 case 3: //Ring
15877 {
15878 if (dofire)
15879 {
15880 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15881 {
15882 ((esPatra*)guys.spr(i))->clk5 = -48;
15883 clk5 = -48;
15884 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15885 }
15886 else
15887 {
15888 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15889 sfx(wpnsfx(wpn),pan(x));
15890 int32_t m=Ewpns.Count()-1;
15891 weapon *ew = (weapon*)(Ewpns.spr(m));
15892
15893 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15894 ((esPatra*)guys.spr(i))->clk5 = 0;
15895 clk5 = 0;
15896 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15897 }
15898 }
15899 if (((esPatra*)guys.spr(i))->clk5 == -16)
15900 {
15901 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15902 sfx(wpnsfx(wpn),pan(x));
15903 int32_t m=Ewpns.Count()-1;
15904 weapon *ew = (weapon*)(Ewpns.spr(m));
15905
15906 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15907 }
15908 break;
15909 }
15910 case 2: //one after another
15911 {
15912 if (dofire)
15913 {
15914 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15915 clk5 = -48 - (12*flycnt2);
15916 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15917 }
15918 if (((esPatra*)guys.spr(i))->clk5 == -16)
15919 {
15920 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15921 sfx(wpnsfx(wpn),pan(x));
15922 }
15923 break;
15924 }
15925 case 1: //random one eye
15926 {
15927 if (dofire && i == randeye)
15928 {
15929 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15930 {
15931 ((esPatra*)guys.spr(i))->clk5 = -48;
15932 clk5 = -48;
15933 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15934 }
15935 else
15936 {
15937 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15938 sfx(wpnsfx(wpn),pan(x));
15939 ((esPatra*)guys.spr(i))->clk5 = 0;
15940 clk5 = 0;
15941 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15942 }
15943 }
15944 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15945 {
15946 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15947 sfx(wpnsfx(wpn),pan(x));
15948 }
15949 break;
15950 }
15951 default: //old behavior, all eyes can fire any time
15952 {
15953
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15954
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15956 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15957 {
15958
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15959 {
15960 ((esPatra*)guys.spr(i))->clk5 = -48;
15961 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15962 }
15963 else
15964 {
15965 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15966 1155 sfx(wpnsfx(wpn),pan(x));
15967 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15968
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15969 }
15970 1155 }
15971
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15972 {
15973 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15974 sfx(wpnsfx(wpn),pan(x));
15975 }
15976 145268 break;
15977 }
15978 }
15979 145268 }
15980 145268 }
15981
15982 }
15983 334429 }
15984 46240 }
15985
15986 160441 adjusted=true;
15987 160441 return enemy::animate(index);
15988 161885 }
15989
15990 249 void ePatra::FirePatraWeapon()
15991 { //.707
15992 249 int32_t xoff = 0;
15993 249 int32_t yoff = 0;
15994
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
15995 {
15996 xoff += hxofs;
15997 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
15998 xoff += (hit_width / 2) - (weap_data.tilew * 8);
15999 else
16000 xoff += (hit_width / 2) - 8;
16001 }
16002
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16003 {
16004 yoff += hyofs;
16005 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16006 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16007 else
16008 yoff += (hit_height / 2) - 8;
16009 }
16010 249 sfx(wpnsfx(wpn),pan(x));
16011 // TODO(crash): check that .add succeeds.
16012
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16013 {
16014 case patrat8SHOT: //Fire Wizzrobe
16015 case patrat4SHOTDIAG:
16016 case patrat4SHOTRAND:
16017 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16018 {
16019 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16020 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16021 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16022 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16023
16024 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16025 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16027 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16028
16029 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16030 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16031 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16032 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16033
16034 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16037 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16038
16039 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16040 }
16041
16042 [[fallthrough]];
16043 case patrat4SHOTCARD: //Stalfos 3
16044 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16047 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16048 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16049 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16050 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16051 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16052 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16053 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16054 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16055 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16056 break;
16057
16058 default:
16059 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16060
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16061 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16062
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16063
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16064 {
16065 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16066 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16068 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16069 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16070 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16072 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16073 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16074 {
16075 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16076 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16077 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16078 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16079 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16080 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16082 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16083 }
16084 }
16085 249 break;
16086
16087 }
16088 249 sfx(wpnsfx(wpn),pan(x));
16089 //+0.46364761
16090 //11.80
16091 249 }
16092
16093 324242 void ePatra::draw(BITMAP *dest)
16094 {
16095 324242 tile=o_tile;
16096 324242 update_enemy_frame();
16097 324242 enemy::draw(dest);
16098 324242 }
16099
16100 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16101 {
16102 int32_t ret = enemy::defend(wpnId, power, edef);
16103
16104 if(ret < 0 && (flycnt||flycnt2))
16105 return 0;
16106
16107 return ret;
16108 }
16109
16110 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16111 {
16112 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16113
16114
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16115 1281 return 0;
16116
16117 452 return ret;
16118 1733 }
16119
16120 190 void ePatra::init_size_flags() {
16121 190 SIZEflags = d->SIZEflags;
16122
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16123
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16124 // al_trace("Enemy txsz:%i\n", txsz);
16125
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16126
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16127
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16128
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16132
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16133
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16134 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16136
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16138 {
16139 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16140 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16141 }
16142
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16143
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16144
16145
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16146
16147 190 }
16148
16149 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16150 1656 {
16151 //cs=8;
16152
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16153 1656 item_set=0;
16154 1656 misc=clk;
16155 1656 clk4 = 0;
16156 1656 clk5 = 0;
16157 1656 clk = -((misc*21)>>1)-1;
16158
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16159 1656 hit_width=12;
16160 1656 hit_height=12;
16161 1656 hxofs=2;
16162 1656 hyofs=2;
16163 1656 extend = 0;
16164 1656 txsz = 1;
16165 1656 tysz = 1;
16166 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16167 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16168 int32_t prntSIZEflags = prntenemy->SIZEflags;
16169 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16170 // al_trace("Enemy txsz:%i\n", txsz);
16171 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16172 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16173 else
16174 hxsz=12;
16175 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16176 else
16177 hysz=12;
16178 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16179 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16180 else
16181 hxofs=2;
16182 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16183 else hyofs=2;
16184 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16185 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16186 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16187 {
16188 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16189 }
16190
16191 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16192 */
16193 1656 mainguy=count_enemy=false;
16194 1656 bgsfx=-1;
16195 //o_tile=0;
16196
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16197 1656 deadsfx = WAV_EDEAD;
16198 1656 hitsfx = WAV_EHIT;
16199 1656 isCore = false;
16200 1656 }
16201
16202 1010584 bool esPatra::animate(int32_t index)
16203 {
16204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16205
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16206 15160 return Dead(index);
16207
16208 995424 return enemy::animate(index);
16209 1010584 }
16210
16211 2028196 void esPatra::draw(BITMAP *dest)
16212 {
16213
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16214 {
16215 1721294 tile = o_tile+(clk&3);
16216
16217
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16218 {
16219 case up: //u
16220 214278 flip=0;
16221 214278 break;
16222
16223 case down: //d
16224 217924 flip=0;
16225 217924 tile+=4;
16226 217924 break;
16227
16228 case left: //l
16229 215346 flip=0;
16230 215346 tile+=8;
16231 215346 break;
16232
16233 case right: //r
16234 215726 flip=0;
16235 215726 tile+=12;
16236 215726 break;
16237
16238 case l_up: //ul
16239 213062 flip=0;
16240 213062 tile+=20;
16241 213062 break;
16242
16243 case r_up: //ur
16244 214350 flip=0;
16245 214350 tile+=24;
16246 214350 break;
16247
16248 case l_down: //dl
16249 215734 flip=0;
16250 215734 tile+=28;
16251 215734 break;
16252
16253 case r_down: //dr
16254 214874 flip=0;
16255 214874 tile+=32;
16256 214874 break;
16257 }
16258 1721294 }
16259 else
16260 {
16261 306902 tile = o_tile+((clk&2)>>1);
16262 }
16263
16264
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16265 1913340 enemy::draw(dest);
16266 2028196 }
16267
16268
16269 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16270 102 {
16271 102 adjusted=false;
16272
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16273
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16274 102 clk4 = 0;
16275 102 clk5 = 0;
16276 //flycnt=6; flycnt2=0;
16277 102 flycnt=dmisc1;
16278 102 flycnt2=0; // PatraBS doesn't have inner rings!
16279 102 loopcnt=0;
16280
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16282
16283 //nets+4480;
16284 102 }
16285
16286 35963 bool ePatraBS::animate(int32_t index)
16287 {
16288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16289
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16290 240 return Dead(index);
16291
16292
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16293 {
16294 4018 removearmos(x,y);
16295 4018 }
16296
16297 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16298
16299
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16300 {
16301 336 clk2=0;
16302
16303
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16304 177 --loopcnt;
16305 else
16306 {
16307
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16308 84 loopcnt=dmisc7;
16309 }
16310
16311 336 ++misc;
16312 336 }
16313
16314 // double size=1;;
16315
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16316 {
16317
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16318 {
16319 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16320
16321
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16322 {
16323 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16324 612 }
16325 else
16326 {
16327 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16328 }
16329
16330 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16331 612 }
16332
16333
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16334 {
16335
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16336 {
16337 131 guys.swap(j,j+1);
16338 131 }
16339
16340 104 --flycnt;
16341 104 }
16342 else
16343 {
16344 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16345
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16346 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16347 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16348
16349
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16350 {
16351 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16352
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16353 77643 }
16354 else
16355 {
16356 75725 guys.spr(i)->x = temp_x;
16357 75725 guys.spr(i)->y = temp_y;
16358 }
16359
16360 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16361 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16362
16363
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16364 {
16365 18812 guys.spr(i)->dir=l_down;
16366 18812 }
16367
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16368 {
16369 18839 guys.spr(i)->dir=left;
16370 18839 }
16371
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16372 {
16373 18802 guys.spr(i)->dir=l_up;
16374 18802 }
16375
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16376 {
16377 20143 guys.spr(i)->dir=up;
16378 20143 }
16379
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16380 {
16381 18517 guys.spr(i)->dir=r_up;
16382 18517 }
16383
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16384 {
16385 18779 guys.spr(i)->dir=right;
16386 18779 }
16387
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16388 {
16389 18992 guys.spr(i)->dir=r_down;
16390 18992 }
16391 else
16392 {
16393 20484 guys.spr(i)->dir=down;
16394 }
16395
16396 153368 guys.spr(i)->x += x;
16397 153368 guys.spr(i)->y += y;
16398 }
16399 153472 }
16400
16401 35723 adjusted=true;
16402 35723 return enemy::animate(index);
16403 35963 }
16404
16405 72874 void ePatraBS::draw(BITMAP *dest)
16406 {
16407 72874 tile=o_tile;
16408
16409
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16410 {
16411 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16412 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16413
16414
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16415 {
16416 19146 lookat=l_down;
16417 19146 }
16418
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16419 {
16420 18298 lookat=down;
16421 18298 }
16422
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16423 {
16424 13624 lookat=r_down;
16425 13624 }
16426
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16427 {
16428 7492 lookat=right;
16429 7492 }
16430
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16431 {
16432 1170 lookat=r_up;
16433 1170 }
16434
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16435 {
16436 964 lookat=up;
16437 964 }
16438
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16439 {
16440 1700 lookat=l_up;
16441 1700 }
16442 else
16443 {
16444 10480 lookat=left;
16445 }
16446
16447
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16448 {
16449 case up: //u
16450 964 flip=0;
16451 964 break;
16452
16453 case down: //d
16454 18298 flip=0;
16455 18298 tile+=8;
16456 18298 break;
16457
16458 case left: //l
16459 10480 flip=0;
16460 10480 tile+=40;
16461 10480 break;
16462
16463 case right: //r
16464 7492 flip=0;
16465 7492 tile+=48;
16466 7492 break;
16467
16468 case l_up: //ul
16469 1700 flip=0;
16470 1700 tile+=80;
16471 1700 break;
16472
16473 case r_up: //ur
16474 1170 flip=0;
16475 1170 tile+=88;
16476 1170 break;
16477
16478 case l_down: //dl
16479 19146 flip=0;
16480 19146 tile+=120;
16481 19146 break;
16482
16483 case r_down: //dr
16484 13624 flip=0;
16485 13624 tile+=128;
16486 13624 break;
16487 }
16488
16489 72874 tile+=(2*(clk&3));
16490 72874 xofs-=8;
16491 72874 yofs-=8;
16492 72874 drawblock(dest,15);
16493 72874 xofs+=8;
16494 72874 yofs+=8;
16495 72874 }
16496 else
16497 {
16498 flip=(clk&1);
16499 xofs-=8;
16500 yofs-=8;
16501 enemy::draw(dest);
16502 xofs+=16;
16503 enemy::draw(dest);
16504 yofs+=16;
16505 enemy::draw(dest);
16506 xofs-=16;
16507 enemy::draw(dest);
16508 xofs+=8;
16509 yofs-=8;
16510 }
16511 72874 }
16512
16513 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16514 {
16515 int32_t ret = enemy::defend(wpnId, power, edef);
16516
16517 if(ret < 0 && (flycnt||flycnt2))
16518 return 0;
16519
16520 return ret;
16521 }
16522
16523 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16524 {
16525 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16526
16527
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16528 81 return 0;
16529
16530 61 return ret;
16531 142 }
16532
16533 102 void ePatraBS::init_size_flags()
16534 {
16535 102 SIZEflags = d->SIZEflags;
16536
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16537 // al_trace("Enemy txsz:%i\n", txsz);
16538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16540 102 else hit_width = 32;
16541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16544 102 else hxofs = -8;
16545
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16546 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16547
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16548
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16549 {
16550 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16551 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16552 }
16553
16554
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16555 102 }
16556
16557 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16558 612 {
16559 //cs=csBOSS;
16560
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16561 612 item_set=0;
16562 612 misc=clk;
16563 612 clk = -((misc*21)>>1)-1;
16564 612 clk4 = 0;
16565 612 clk5 = 0;
16566
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16567 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16568
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16569 // al_trace("Enemy txsz:%i\n", txsz);
16570
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16572 612 else hit_width=16;
16573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16574 612 else hit_height=16;
16575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16576
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16578 612 else hyofs=2;
16579 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16580
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16582 {
16583 yofs = (int32_t)prntenemy->yofs;
16584 }
16585
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16586
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16587
16588 612 bgsfx=-1;
16589 612 mainguy=count_enemy=false;
16590 612 deadsfx = WAV_EDEAD;
16591 612 hitsfx = WAV_EHIT;
16592
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16593 612 isCore = false;
16594 612 }
16595
16596 155090 bool esPatraBS::animate(int32_t index)
16597 {
16598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16599
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16600 1552 return Dead(index);
16601
16602 153538 return enemy::animate(index);
16603 155090 }
16604
16605 315868 void esPatraBS::draw(BITMAP *dest)
16606 {
16607 315868 tile=o_tile;
16608
16609
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16610 {
16611
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16612 {
16613 case up: //u
16614 41612 flip=0;
16615 41612 break;
16616
16617 case down: //d
16618 42622 flip=0;
16619 42622 tile+=4;
16620 42622 break;
16621
16622 case left: //l
16623 37916 flip=0;
16624 37916 tile+=8;
16625 37916 break;
16626
16627 case right: //r
16628 38458 flip=0;
16629 38458 tile+=12;
16630 38458 break;
16631
16632 case l_up: //ul
16633 38564 flip=0;
16634 38564 tile+=20;
16635 38564 break;
16636
16637 case r_up: //ur
16638 38568 flip=0;
16639 38568 tile+=24;
16640 38568 break;
16641
16642 case l_down: //dl
16643 38662 flip=0;
16644 38662 tile+=28;
16645 38662 break;
16646
16647 case r_down: //dr
16648 39466 flip=0;
16649 39466 tile+=32;
16650 39466 break;
16651 }
16652
16653 315868 tile += ((clk&6)>>1);
16654 315868 }
16655 else
16656 {
16657 tile += (clk&4)?1:0;
16658 }
16659
16660
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16661 283752 enemy::draw(dest);
16662 315868 }
16663
16664 351473 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16665 {
16666
4/6
✓ Branch 0 taken 242582 times.
✓ Branch 1 taken 108891 times.
✓ Branch 2 taken 242582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242582 times.
✗ Branch 5 not taken.
351473 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16667
4/8
✓ Branch 0 taken 351473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351473 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351473 times.
✗ Branch 7 not taken.
351473 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16668
1/2
✓ Branch 0 taken 351473 times.
✗ Branch 1 not taken.
351473 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16669 351473 }
16670
16671 77344 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16672 {
16673 // Kludge
16674
4/8
✓ Branch 0 taken 77344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77344 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 77344 times.
✗ Branch 7 not taken.
77344 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16675 77344 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77344 times.
77344 delete w;
16677 77344 return ret;
16678 }
16679
16680 9565 void enemy_scored(int32_t index)
16681 {
16682 9565 ((enemy*)guys.spr(index))->scored=true;
16683 9565 }
16684
16685 2198 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16686 {
16687
5/8
✓ Branch 0 taken 2198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 286 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2198 times.
✗ Branch 7 not taken.
2198 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16688
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 765 times.
2198 if (isdungeon(g->screen_spawned))
16689 765 g->y += 1;
16690
5/6
✓ Branch 0 taken 1284 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2198 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16691 {
16692 4 g->o_tile = parentscr->guytile;
16693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16694 4 g->flags &= ~guy_invisible;
16695 4 g->cs = parentscr->guycs;
16696 4 }
16697 2198 guys.add(g);
16698 2198 }
16699
16700 23822 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16701 {
16702
4/8
✓ Branch 0 taken 23822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23822 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23822 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23822 times.
✗ Branch 7 not taken.
23822 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16703 23822 items.add(i);
16704 23822 }
16705
16706 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16707 {
16708
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16709 150 items.add(i);
16710 150 }
16711
16712 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16713 {
16714
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16715 3 items.add(i);
16716 3 }
16717
16718 20075 void add_item_for_screen(int32_t screen, item* item)
16719 {
16720 20075 item->screen_spawned = screen;
16721 20075 items.add(item);
16722 20075 }
16723
16724 103 void kill_em_all()
16725 {
16726
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 103 times.
464 for(int32_t i=0; i<guys.Count(); i++)
16727 {
16728 361 enemy *e = ((enemy*)guys.spr(i));
16729
16730
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 331 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
361 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16731
16732 331 e->kickbucket();
16733 331 }
16734 103 }
16735
16736 bool can_kill_em_all()
16737 {
16738 for(int32_t i=0; i<guys.Count(); i++)
16739 {
16740 enemy *e = ((enemy*)guys.spr(i));
16741
16742 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16743 if(e->superman) continue;
16744 return true;
16745 }
16746 return false;
16747 }
16748
16749 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16750 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16751 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16752 {
16753 for(int32_t i=0; i<guys.Count(); i++)
16754 {
16755 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16756 {
16757 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16758 &&(((enemy*)guys.spr(i))->d->type != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16759 {
16760 return i;
16761 }
16762 }
16763 }
16764
16765 return -1;
16766 }
16767
16768 13654215 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16769 {
16770
4/4
✓ Branch 0 taken 16611 times.
✓ Branch 1 taken 13637604 times.
✓ Branch 2 taken 34780570 times.
✓ Branch 3 taken 13622767 times.
48403337 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16771 {
16772
2/2
✓ Branch 0 taken 31448 times.
✓ Branch 1 taken 34749122 times.
34780570 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16773 {
16774 31448 return i;
16775 }
16776 34749122 }
16777
16778 13622767 return -1;
16779 13654215 }
16780
16781 // For Hero's hit detection. Count them if they are dying.
16782 54760 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16783 {
16784 54760 enemy *e = (enemy*)guys.spr(index);
16785
3/4
✓ Branch 0 taken 54760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 25180 times.
54760 if(!e || e->hp > 0)
16786 29580 return -1;
16787
16788 25180 bool d = e->dying;
16789 25180 int32_t hc = e->hclk;
16790 25180 e->dying = false;
16791 25180 e->hclk = 0;
16792 25180 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16793 25180 e->dying = d;
16794 25180 e->hclk = hc;
16795
16796
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 25023 times.
25180 return hit ? index : -1;
16797 54760 }
16798
16799 15199867 bool hasMainGuy(int screen)
16800 {
16801
2/2
✓ Branch 0 taken 16384185 times.
✓ Branch 1 taken 6125868 times.
22510053 for(int32_t i=0; i<guys.Count(); i++)
16802 {
16803 16384185 enemy* e = (enemy*)guys.spr(i);
16804
4/4
✓ Branch 0 taken 15921101 times.
✓ Branch 1 taken 463084 times.
✓ Branch 2 taken 9073999 times.
✓ Branch 3 taken 6847102 times.
16384185 if (e->screen_spawned == screen && e->mainguy)
16805 {
16806 9073999 return true;
16807 }
16808 7310186 }
16809
16810 6125868 return false;
16811 15199867 }
16812
16813 143 void EatHero(int32_t index)
16814 {
16815 143 ((eStalfos*)guys.spr(index))->eathero();
16816 143 }
16817
16818 9 void GrabHero(int32_t index)
16819 {
16820 9 ((eWallM*)guys.spr(index))->grabhero();
16821 9 }
16822
16823 1338 bool CarryHero()
16824 {
16825
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16826 {
16827
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->type==eeWALLM)
16828 {
16829
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16830 {
16831 1338 Hero.x=guys.spr(i)->x;
16832 1338 Hero.y=guys.spr(i)->y;
16833 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16834 }
16835 505 }
16836
16837 // Like Likes currently can't carry Hero.
16838 /*
16839 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16840 {
16841 if(((eLikeLike*)guys.spr(i))->hashero)
16842 {
16843 Hero.x=guys.spr(i)->x;
16844 Hero.y=guys.spr(i)->y;
16845 return (true);
16846 }
16847 }*/
16848 2595 }
16849
16850 return false;
16851 1338 }
16852
16853 // Move item with guy
16854 void movefairy(zfix &x,zfix &y,int32_t misc)
16855 {
16856 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16857
16858 if(i!=-1)
16859 {
16860 x = guys.spr(i)->x;
16861 y = guys.spr(i)->y;
16862 }
16863 }
16864
16865 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16866 void movefairy2(zfix x,zfix y,int32_t misc)
16867 {
16868 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16869
16870 if(i!=-1)
16871 {
16872 guys.spr(i)->x = x;
16873 guys.spr(i)->y = y;
16874 }
16875 }// Move item with guy
16876
16877 61175 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16878 {
16879 61175 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16880
16881
1/2
✓ Branch 0 taken 61175 times.
✗ Branch 1 not taken.
61175 if(fairy)
16882 {
16883 61175 x = fairy->x;
16884 61175 y = fairy->y;
16885 61175 }
16886 61175 }
16887
16888 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16889 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16890 {
16891 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16892
16893
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16894 {
16895 404 fairy->x = x;
16896 404 fairy->y = y;
16897 404 }
16898 404 }
16899
16900 void killfairy(int32_t misc)
16901 {
16902 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16903 guys.del(i);
16904 }
16905
16906 223 int32_t getGuyIndex(const int32_t eid)
16907 {
16908
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 for(word i = 0; i < guys.Count(); i++)
16909 {
16910
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 623 times.
846 if(guys.spr(i)->getUID() == eid)
16911 223 return i;
16912 623 }
16913
16914 return -1;
16915 223 }
16916
16917 223 void killfairynew(item const &itemfairy)
16918 {
16919 223 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16920
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16921 223 }
16922
16923 //Should probably change this to return an 'enemy*', null on failure -Em
16924 22075 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16925 {
16926 22075 return addenemy_z(screen,x,y,0,id,clk);
16927 }
16928
16929 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16930 {
16931 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16932 }
16933
16934 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16935 {
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16937
16938 1997 int32_t ret = 0;
16939 1997 sprite *e=NULL;
16940
16941
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].type)
16942 {
16943 //Fixme: possible enemy memory leak. (minor)
16944 case eeWALK:
16945
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16946 110 break;
16947
16948 case eeLEV:
16949 e = new eLeever((zfix)x,(zfix)y,id,clk);
16950 break;
16951
16952 case eeTEK:
16953 e = new eTektite((zfix)x,(zfix)y,id,clk);
16954 break;
16955
16956 case eePEAHAT:
16957 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16958 break;
16959
16960 case eeZORA:
16961 e = new eZora((zfix)x,(zfix)y,id,clk);
16962 break;
16963
16964 case eeGHINI:
16965 e = new eGhini((zfix)x,(zfix)y,id,clk);
16966 break;
16967
16968 case eeKEESE:
16969
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16970 1865 break;
16971
16972 case eeWIZZ:
16973
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16974 15 break;
16975
16976 case eePROJECTILE:
16977 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16978 break;
16979
16980 case eeWALLM:
16981 e = new eWallM((zfix)x,(zfix)y,id,clk);
16982 break;
16983
16984 case eeAQUA:
16985 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
16986 break;
16987
16988 case eeMOLD:
16989 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16990 break;
16991
16992 case eeMANHAN:
16993
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
16994 1 break;
16995
16996 case eeGLEEOK:
16997 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16998 break;
16999
17000 case eeGHOMA:
17001 e = new eGohma((zfix)x,(zfix)y,id,clk);
17002 break;
17003
17004 case eeLANM:
17005 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17006 break;
17007
17008 case eeGANON:
17009 e = new eGanon((zfix)x,(zfix)y,id,clk);
17010 break;
17011
17012 case eeFAIRY:
17013 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17014 break;
17015
17016 case eeFIRE:
17017
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17018 2 break;
17019
17020 case eeOTHER:
17021 e = new eOther((zfix)x,(zfix)y,id,clk);
17022 break;
17023
17024
17025 case eeSCRIPT01:
17026 case eeSCRIPT02:
17027 case eeSCRIPT03:
17028 case eeSCRIPT04:
17029 case eeSCRIPT05:
17030 case eeSCRIPT06:
17031 case eeSCRIPT07:
17032 case eeSCRIPT08:
17033 case eeSCRIPT09:
17034 case eeSCRIPT10:
17035 case eeSCRIPT11:
17036 case eeSCRIPT12:
17037 case eeSCRIPT13:
17038 case eeSCRIPT14:
17039 case eeSCRIPT15:
17040 case eeSCRIPT16:
17041 case eeSCRIPT17:
17042 case eeSCRIPT18:
17043 case eeSCRIPT19:
17044 case eeSCRIPT20:
17045 {
17046 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17047 {
17048 e = new eScript((zfix)x,(zfix)y,id,clk);
17049 break;
17050 }
17051 else return 0;
17052 }
17053
17054 case eeFFRIENDLY01:
17055 case eeFFRIENDLY02:
17056 case eeFFRIENDLY03:
17057 case eeFFRIENDLY04:
17058 case eeFFRIENDLY05:
17059 case eeFFRIENDLY06:
17060 case eeFFRIENDLY07:
17061 case eeFFRIENDLY08:
17062 case eeFFRIENDLY09:
17063 case eeFFRIENDLY10:
17064 {
17065 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17066 {
17067 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17068 }
17069 else return 0;
17070
17071 }
17072
17073 case eeSPINTILE:
17074 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17075 break;
17076
17077 // and these enemies use the misc10/misc2 value
17078 case eeROCK:
17079 {
17080 switch(guysbuf[id&0xFFF].attributes[9])
17081 {
17082 case 1:
17083 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17084 break;
17085
17086 case 0:
17087 default:
17088 e = new eRock((zfix)x,(zfix)y,id,clk);
17089 break;
17090 }
17091
17092 break;
17093 }
17094
17095 case eeTRAP:
17096 {
17097 switch(guysbuf[id&0xFFF].attributes[1])
17098 {
17099 case 1:
17100 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17101 break;
17102
17103 case 0:
17104 default:
17105 e = new eTrap((zfix)x,(zfix)y,id,clk);
17106 break;
17107 }
17108
17109 break;
17110 }
17111
17112 case eeDONGO:
17113 {
17114 switch(guysbuf[id&0xFFF].attributes[9])
17115 {
17116 case 1:
17117 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17118 break;
17119
17120 case 0:
17121 default:
17122 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17123 break;
17124 }
17125
17126 break;
17127 }
17128
17129 case eeDIG:
17130 {
17131
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17132 {
17133 case 1:
17134 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17135 break;
17136
17137 4 case 0:
17138 default:
17139
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17140 4 break;
17141 }
17142
17143 4 break;
17144 }
17145
17146 case eePATRA:
17147 {
17148 switch(guysbuf[id&0xFFF].attributes[9])
17149 {
17150 case 1:
17151 if (get_qr(qr_HARDCODED_BS_PATRA))
17152 {
17153 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17154 break;
17155 }
17156 [[fallthrough]];
17157 case 0:
17158 default:
17159 e = new ePatra((zfix)x,(zfix)y,id,clk);
17160 break;
17161 }
17162
17163 break;
17164 }
17165
17166 case eeGUY:
17167 {
17168 switch(guysbuf[id&0xFFF].attributes[9])
17169 {
17170 case 1:
17171 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17172 break;
17173
17174 case 0:
17175 default:
17176 e = new eNPC((zfix)x,(zfix)y,id,clk);
17177 break;
17178 }
17179
17180 break;
17181 }
17182
17183 case eeNONE:
17184 if(guysbuf[id&0xFFF].attributes[9] ==1)
17185 {
17186 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17187 break;
17188 break;
17189 }
17190 [[fallthrough]];
17191 default:
17192
17193 return 0;
17194 }
17195
17196 1997 ret++; // Made one enemy.
17197
17198
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17199 {
17200 7 e->z = (zfix)z;
17201 7 }
17202
17203
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17204 1997 e->setParent(parent);
17205
17206
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17207 {
17208 return 0;
17209 }
17210
17211 // add segments of segmented enemies
17212 1997 int32_t c=0;
17213
17214
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].type)
17215 {
17216 case eeMOLD:
17217 {
17218 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17219 id &= 0xFFF;
17220
17221 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17222 {
17223 //christ this is messy -DD
17224 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17225
17226 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17227 {
17228 al_trace("Moldorm segment %d could not be created!\n",i+1);
17229
17230 for(int32_t j=0; j<i+1; j++)
17231 guys.del(guys.Count()-1);
17232
17233 return 0;
17234 }
17235
17236 if(i>0)
17237 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17238
17239 ret++;
17240 }
17241
17242 break;
17243 }
17244
17245 case eeLANM:
17246 {
17247 id &= 0xFFF;
17248 int32_t shft = guysbuf[id].attributes[1];
17249 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17250
17251 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17252 {
17253 al_trace("Lanmola segment 1 could not be created!\n");
17254 guys.del(guys.Count()-1);
17255 return 0;
17256 }
17257
17258 ret++;
17259
17260 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17261 {
17262 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17263 {
17264 al_trace("Lanmola segment %d could not be created!\n",i+1);
17265
17266 for(int32_t j=0; j<i+1; j++)
17267 guys.del(guys.Count()-1);
17268
17269 return 0;
17270 }
17271
17272 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17273 ret++;
17274 }
17275 }
17276 break;
17277
17278 case eeMANHAN:
17279 1 id &= 0xFFF;
17280
17281
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17282 {
17283
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17284 {
17285 al_trace("Manhandla head %d could not be created!\n",i+1);
17286
17287 for(int32_t j=0; j<i+1; j++)
17288 {
17289 guys.del(guys.Count()-1);
17290 }
17291
17292 return 0;
17293 }
17294
17295 4 ret++;
17296 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17297 4 }
17298
17299 1 break;
17300
17301 case eeGLEEOK:
17302 {
17303 id &= 0xFFF;
17304
17305 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17306 {
17307 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17308 {
17309 al_trace("Gleeok head %d could not be created!\n",i+1);
17310
17311 for(int32_t j=0; j<i+1; j++)
17312 {
17313 guys.del(guys.Count()-1);
17314 }
17315
17316 return false;
17317 }
17318
17319 c-=guysbuf[id].attributes[3];
17320 ret++;
17321 }
17322 }
17323 break;
17324
17325
17326 case eePATRA:
17327 {
17328 id &= 0xFFF;
17329 int32_t outeyes = 0;
17330
17331 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17332 {
17333 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17334 {
17335 al_trace("Patra outer eye %d could not be created!\n",i+1);
17336
17337 for(int32_t j=0; j<i+1; j++)
17338 guys.del(guys.Count()-1);
17339
17340 return 0;
17341 }
17342 else
17343 outeyes++;
17344
17345 ret++;
17346 }
17347
17348 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17349 {
17350 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17351 {
17352 al_trace("Patra inner eye %d could not be created!\n",i+1);
17353
17354 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17355 guys.del(guys.Count()-1);
17356
17357 return 0;
17358 }
17359
17360 ret++;
17361 }
17362
17363 break;
17364 }
17365 }
17366
17367
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17368 {
17369 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17370 2001 e->screen_spawned = screen;
17371 2001 }
17372
17373 1997 return ret;
17374 1997 }
17375
17376 // Returns number of enemies/segments created
17377 106085 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17378 {
17379 106085 int32_t realid = id&0xFFF;
17380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106085 times.
106085 if( realid > MAXGUYS )
17381 {
17382 return 0;
17383 }
17384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106085 times.
106085 if(id <= 0) return 0;
17385
17386 106085 int32_t ret = 0;
17387 106085 sprite *e=NULL;
17388
17389
29/31
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52443 times.
✓ Branch 4 taken 4434 times.
✓ Branch 5 taken 5303 times.
✓ Branch 6 taken 1833 times.
✓ Branch 7 taken 2874 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 12539 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4433 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 736 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7780 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2573 times.
✓ Branch 26 taken 257 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
106085 switch(guysbuf[id&0xFFF].type)
17390 {
17391 //Fixme: possible enemy memory leak. (minor)
17392 case eeWALK:
17393
3/6
✓ Branch 0 taken 52443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52443 times.
✗ Branch 5 not taken.
52443 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17394 52443 break;
17395
17396 case eeLEV:
17397
3/6
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4434 times.
✗ Branch 5 not taken.
4434 e = new eLeever((zfix)x,(zfix)y,id,clk);
17398 4434 break;
17399
17400 case eeTEK:
17401
3/6
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5303 times.
✗ Branch 5 not taken.
5303 e = new eTektite((zfix)x,(zfix)y,id,clk);
17402 5303 break;
17403
17404 case eePEAHAT:
17405
3/6
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1833 times.
✗ Branch 5 not taken.
1833 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17406 1833 break;
17407
17408 case eeZORA:
17409
3/6
✓ Branch 0 taken 2874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2874 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2874 times.
✗ Branch 5 not taken.
2874 e = new eZora((zfix)x,(zfix)y,id,clk);
17410 2874 break;
17411
17412 case eeGHINI:
17413
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17414 461 break;
17415
17416 case eeKEESE:
17417
3/6
✓ Branch 0 taken 12539 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12539 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12539 times.
✗ Branch 5 not taken.
12539 e = new eKeese((zfix)x,(zfix)y,id,clk);
17418 12539 break;
17419
17420 case eeWIZZ:
17421
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17422 5335 break;
17423
17424 case eePROJECTILE:
17425
3/6
✓ Branch 0 taken 4433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4433 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4433 times.
✗ Branch 5 not taken.
4433 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17426 4433 break;
17427
17428 case eeWALLM:
17429
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17430 998 break;
17431
17432 case eeAQUA:
17433
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17434 126 break;
17435
17436 case eeMOLD:
17437
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17438 618 break;
17439
17440 case eeMANHAN:
17441
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17442 149 break;
17443
17444 case eeGLEEOK:
17445
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17446 168 break;
17447
17448 case eeGHOMA:
17449
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17450 93 break;
17451
17452 case eeLANM:
17453
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17454 420 break;
17455
17456 case eeGANON:
17457
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17458 13 break;
17459
17460 case eeFAIRY:
17461
3/6
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 736 times.
✗ Branch 5 not taken.
736 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17462 736 break;
17463
17464 case eeFIRE:
17465
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17466 758 break;
17467
17468 case eeOTHER:
17469
3/6
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7780 times.
✗ Branch 5 not taken.
7780 e = new eOther((zfix)x,(zfix)y,id,clk);
17470 7780 break;
17471
17472
17473 case eeSCRIPT01:
17474 case eeSCRIPT02:
17475 case eeSCRIPT03:
17476 case eeSCRIPT04:
17477 case eeSCRIPT05:
17478 case eeSCRIPT06:
17479 case eeSCRIPT07:
17480 case eeSCRIPT08:
17481 case eeSCRIPT09:
17482 case eeSCRIPT10:
17483 case eeSCRIPT11:
17484 case eeSCRIPT12:
17485 case eeSCRIPT13:
17486 case eeSCRIPT14:
17487 case eeSCRIPT15:
17488 case eeSCRIPT16:
17489 case eeSCRIPT17:
17490 case eeSCRIPT18:
17491 case eeSCRIPT19:
17492 case eeSCRIPT20:
17493 {
17494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17495 {
17496
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eScript((zfix)x,(zfix)y,id,clk);
17497 30 break;
17498 }
17499 else return 0;
17500 }
17501
17502 case eeFFRIENDLY01:
17503 case eeFFRIENDLY02:
17504 case eeFFRIENDLY03:
17505 case eeFFRIENDLY04:
17506 case eeFFRIENDLY05:
17507 case eeFFRIENDLY06:
17508 case eeFFRIENDLY07:
17509 case eeFFRIENDLY08:
17510 case eeFFRIENDLY09:
17511 case eeFFRIENDLY10:
17512 {
17513 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17514 {
17515 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17516 }
17517 else return 0;
17518
17519 }
17520
17521 case eeSPINTILE:
17522
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17523 94 break;
17524
17525 // and these enemies use the misc10/misc2 value
17526 case eeROCK:
17527 {
17528
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17529 {
17530 case 1:
17531
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17532 30 break;
17533
17534 354 case 0:
17535 default:
17536
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17537 354 break;
17538 }
17539
17540 384 break;
17541 }
17542
17543 case eeTRAP:
17544 {
17545
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✓ Branch 2 taken 1680 times.
2573 switch(guysbuf[id&0xFFF].attributes[1])
17546 {
17547 case 1:
17548
3/6
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 893 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 893 times.
✗ Branch 5 not taken.
893 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17549 893 break;
17550
17551 1680 case 0:
17552 default:
17553
3/6
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1680 times.
✗ Branch 5 not taken.
1680 e = new eTrap((zfix)x,(zfix)y,id,clk);
17554 1680 break;
17555 }
17556
17557 2573 break;
17558 }
17559
17560 case eeDONGO:
17561 {
17562
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 209 times.
257 switch(guysbuf[id&0xFFF].attributes[9])
17563 {
17564 case 1:
17565
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17566 48 break;
17567
17568 209 case 0:
17569 default:
17570
3/6
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 209 times.
✗ Branch 5 not taken.
209 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17571 209 break;
17572 }
17573
17574 257 break;
17575 }
17576
17577 case eeDIG:
17578 {
17579
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17580 {
17581 case 1:
17582
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17583 327 break;
17584
17585 76 case 0:
17586 default:
17587
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17588 76 break;
17589 }
17590
17591 403 break;
17592 }
17593
17594 case eePATRA:
17595 {
17596
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17597 {
17598 case 1:
17599
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17600 {
17601
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17602 102 break;
17603 }
17604 [[fallthrough]];
17605 190 case 0:
17606 default:
17607
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17608 190 break;
17609 }
17610
17611 292 break;
17612 }
17613
17614 case eeGUY:
17615 {
17616
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17617 {
17618 case 1:
17619 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17620 break;
17621
17622 5 case 0:
17623 default:
17624
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17625 5 break;
17626 }
17627
17628 5 break;
17629 }
17630
17631 case eeNONE:
17632
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17633 {
17634
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17635 533 break;
17636 }
17637 [[fallthrough]];
17638 default:
17639
17640 return 0;
17641 }
17642
17643 106085 ret++; // Made one enemy.
17644
17645
4/4
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 105807 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 232 times.
106085 if(z && canfall(id))
17646 {
17647 232 e->z = (zfix)z;
17648 232 }
17649
17650
2/2
✓ Branch 0 taken 105807 times.
✓ Branch 1 taken 278 times.
106085 ((enemy*)e)->ceiling = (z && canfall(id));
17651
17652
1/2
✓ Branch 0 taken 106085 times.
✗ Branch 1 not taken.
106085 if(!guys.add(e))
17653 {
17654 return 0;
17655 }
17656
17657 // add segments of segmented enemies
17658 106085 int32_t c=0;
17659
17660
6/6
✓ Branch 0 taken 104438 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
106085 switch(guysbuf[id&0xFFF].type)
17661 {
17662 case eeMOLD:
17663 {
17664 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17665 618 id &= 0xFFF;
17666
17667
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17668 {
17669 //christ this is messy -DD
17670 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17671
17672
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17673 {
17674 al_trace("Moldorm segment %d could not be created!\n",i+1);
17675
17676 for(int32_t j=0; j<i+1; j++)
17677 guys.del(guys.Count()-1);
17678
17679 return 0;
17680 }
17681
17682
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17683 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17684
17685 3150 ret++;
17686 3150 }
17687
17688 618 break;
17689 }
17690
17691 case eeLANM:
17692 {
17693 420 id &= 0xFFF;
17694 420 int32_t shft = guysbuf[id].attributes[1];
17695 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17696
17697
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17698 {
17699 al_trace("Lanmola segment 1 could not be created!\n");
17700 guys.del(guys.Count()-1);
17701 return 0;
17702 }
17703
17704 420 ret++;
17705
17706
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17707 {
17708
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17709 {
17710 al_trace("Lanmola segment %d could not be created!\n",i+1);
17711
17712 for(int32_t j=0; j<i+1; j++)
17713 guys.del(guys.Count()-1);
17714
17715 return 0;
17716 }
17717
17718 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17719 1847 ret++;
17720 1847 }
17721 }
17722 420 break;
17723
17724 case eeMANHAN:
17725 149 id &= 0xFFF;
17726
17727
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17728 {
17729
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17730 {
17731 al_trace("Manhandla head %d could not be created!\n",i+1);
17732
17733 for(int32_t j=0; j<i+1; j++)
17734 {
17735 guys.del(guys.Count()-1);
17736 }
17737
17738 return 0;
17739 }
17740
17741 688 ret++;
17742 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17743 688 }
17744
17745 149 break;
17746
17747 case eeGLEEOK:
17748 {
17749 168 id &= 0xFFF;
17750 168 eGleeok* parent = (eGleeok*)e;
17751
17752
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17753 {
17754
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17755
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17756 {
17757 al_trace("Gleeok head %d could not be created!\n",i+1);
17758
17759 for(int32_t j=0; j<i+1; j++)
17760 {
17761 guys.del(guys.Count()-1);
17762 }
17763
17764 return false;
17765 }
17766
17767 533 head->necktile=parent->necktile;
17768 533 head->dummy_int[1]=parent->necktile;
17769
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17770 {
17771 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17772 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17773 421 }
17774 else
17775 {
17776 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17777 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17778 }
17779 533 head->tile = head->dummy_int[2];
17780
17781 533 c-=guysbuf[id].attributes[3];
17782 533 ret++;
17783 533 }
17784 }
17785 168 break;
17786
17787
17788 case eePATRA:
17789 {
17790 292 id &= 0xFFF;
17791 292 int32_t outeyes = 0;
17792
17793
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17794 {
17795
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17796 {
17797 al_trace("Patra outer eye %d could not be created!\n",i+1);
17798
17799 for(int32_t j=0; j<i+1; j++)
17800 guys.del(guys.Count()-1);
17801
17802 return 0;
17803 }
17804 else
17805 1956 outeyes++;
17806
17807 1956 ret++;
17808 1956 }
17809
17810
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17811 {
17812
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17813 {
17814 al_trace("Patra inner eye %d could not be created!\n",i+1);
17815
17816 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17817 guys.del(guys.Count()-1);
17818
17819 return 0;
17820 }
17821
17822 312 ret++;
17823 312 }
17824
17825 292 break;
17826 }
17827 }
17828
17829
2/2
✓ Branch 0 taken 114991 times.
✓ Branch 1 taken 106085 times.
221076 for (int i = 0; i < ret; i++)
17830 {
17831 114991 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17832 114991 e->screen_spawned = screen;
17833 114991 }
17834
17835 106085 return ret;
17836 106085 }
17837
17838 2069977 bool isjumper(int32_t id)
17839 {
17840
2/4
✓ Branch 0 taken 2069977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2069977 times.
2069977 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17841 {
17842 return false;
17843 }
17844
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1963949 times.
✓ Branch 2 taken 106019 times.
2069977 switch(guysbuf[id&0xFFF].type)
17845 {
17846 case eeROCK:
17847 case eeTEK:
17848 9 return true;
17849
17850 case eeWALK:
17851
3/4
✓ Branch 0 taken 106019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93754 times.
106019 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17852 93754 }
17853
17854 2057703 return false;
17855 2069977 }
17856
17857
17858 8068 bool isfixedtogrid(int32_t id)
17859 {
17860
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17861 {
17862 return false;
17863 }
17864
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].type)
17865 {
17866 case eeWALK:
17867 case eeLEV:
17868 case eeZORA:
17869 case eeDONGO:
17870 case eeGANON:
17871 case eeROCK:
17872 case eeGLEEOK:
17873 case eeAQUA:
17874 case eeLANM:
17875 return true;
17876 }
17877
17878 8068 return false;
17879 8068 }
17880
17881 // Can't fall, can have Z value.
17882 78266434 bool isflier(int32_t id)
17883 {
17884
3/4
✓ Branch 0 taken 78266434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 78155576 times.
78266434 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17885 {
17886 110858 return false;
17887 }
17888
2/2
✓ Branch 0 taken 14392561 times.
✓ Branch 1 taken 63763015 times.
78155576 switch(guysbuf[id&0xFFF].type) //id&0x0FFF)
17889 {
17890 case eePEAHAT:
17891 case eeKEESE:
17892 case eePATRA:
17893 case eeFAIRY:
17894 case eeGHINI:
17895
17896 // Could theoretically have their Z set by a script
17897 case eeFIRE:
17898 14392561 return true;
17899 break;
17900 }
17901
17902 63763015 return false;
17903 78266434 }
17904
17905 // Can't have Z position
17906 4056840 bool never_in_air(int32_t id)
17907 {
17908
2/4
✓ Branch 0 taken 4056840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4056840 times.
4056840 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17909 {
17910 return false;
17911 }
17912
2/2
✓ Branch 0 taken 4047248 times.
✓ Branch 1 taken 9592 times.
4056840 switch(guysbuf[id&0xFFF].type)
17913 {
17914 case eeMANHAN:
17915 case eeMOLD:
17916 case eeLANM:
17917 case eeGLEEOK:
17918 case eeZORA:
17919 case eeLEV:
17920 case eeAQUA:
17921 case eeROCK:
17922 case eeGANON:
17923 case eeTRAP:
17924 case eePROJECTILE:
17925 case eeSPINTILE:
17926 9592 return true;
17927 }
17928
17929 4047248 return false;
17930 4056840 }
17931
17932 2258945 bool canfall(int32_t id)
17933 {
17934
3/4
✓ Branch 0 taken 2258945 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2258899 times.
2258945 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17935 {
17936 46 return false;
17937 }
17938
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2258859 times.
✓ Branch 2 taken 40 times.
2258899 switch(guysbuf[id&0xFFF].type)
17939 {
17940 case eeGUY:
17941 {
17942
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17943 40 return false;
17944
17945 switch(guysbuf[id&0xFFF].attributes[9])
17946 {
17947 case 1:
17948 case 2:
17949 return true;
17950
17951 case 0:
17952 case 3:
17953 default:
17954 return false;
17955 }
17956
17957 case eeGHOMA:
17958 case eeDIG:
17959 return false;
17960 }
17961 }
17962
17963
17964
4/4
✓ Branch 0 taken 2250381 times.
✓ Branch 1 taken 8478 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2069977 times.
2258859 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17965 2258945 }
17966
17967 60437750 bool enemy::enemycanfall(int32_t id, bool checkgrav) const
17968 {
17969
3/4
✓ Branch 0 taken 60437750 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 60348152 times.
60437750 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17970 {
17971 89598 return false;
17972 }
17973 //Z_scripterrlog("canfall family is %d:\n", family);
17974 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17975 //if ( family == eeFIRE && id >= eSTART )
17976 //{
17977 // Z_scripterrlog("eeFire\n");
17978 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17979 //}
17980
17981 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17982
17983
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 57841740 times.
✓ Branch 2 taken 2077477 times.
60348152 switch(guysbuf[id&0xFFF].type)
17984 {
17985 case eeGUY:
17986 {
17987
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
17988 2077477 return false;
17989
17990 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
17991 {
17992 case 1:
17993 case 2:
17994 return true;
17995
17996 case 0:
17997 case 3:
17998 default:
17999 return false;
18000 }
18001
18002 case eeGHOMA:
18003 case eeDIG:
18004 428935 return false;
18005 }
18006 }
18007
18008
2/2
✓ Branch 0 taken 40224377 times.
✓ Branch 1 taken 17617363 times.
57841740 if(!checkgrav) return true;
18009 40224377 return (moveflags & move_obeys_grav);
18010
18011 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18012 // {
18013 // if ( moveflags & move_obeys_grav ) return true;
18014 // else return false;
18015 // }
18016 // else
18017 // {
18018 // return (moveflags & move_obeys_grav);
18019 // }
18020 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18021 60437750 }
18022
18023 1278 void addfires()
18024 {
18025
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 457 times.
1278 if(!get_qr(qr_NOGUYFIRES))
18026 {
18027 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18028 457 int32_t bs = get_qr(qr_BSZELDA);
18029 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18030 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18031 457 }
18032 1278 }
18033
18034 // This function runs one time for every screen on the first frame of a region being loaded.
18035 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18036 38702 static void loadguys(mapscr* scr)
18037 {
18038 38702 int screen = scr->screen;
18039 38702 byte Guy=0;
18040 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18041 // Else use mITEM and ipONETIME
18042 38702 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18043 38702 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18044
18045 38702 mapscr* guyscr = scr;
18046
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 37796 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
38702 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18047 {
18048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18049 {
18050 431 Guy=special_warp_return_scr->guy;
18051 431 guyscr = special_warp_return_scr;
18052 431 }
18053 431 }
18054 else
18055 {
18056 38271 Guy=scr->guy;
18057
2/2
✓ Branch 0 taken 1669 times.
✓ Branch 1 taken 36602 times.
38271 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18058 36602 mark_visited(screen);
18059 }
18060
18061 119036 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18062
18063 38702 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18064 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18065
4/4
✓ Branch 0 taken 3872 times.
✓ Branch 1 taken 34830 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1322 times.
38702 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18066 {
18067
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1311 times.
1322 if(scr->room==rZELDA)
18068 {
18069 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18070 11 guys.spr(0)->hxofs=1000;
18071 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18072 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18073 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18074 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18075 11 return;
18076 }
18077
18078
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 11 times.
2611 bool ffire = oldguy
18079
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18080 11 : (guyscr->roomflags&RFL_GUYFIRES);
18081
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1278 times.
1311 if(ffire)
18082 1278 addfires();
18083
18084
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 425 times.
1311 if(screen>=128)
18085
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18086 13 Guy=0;
18087
18088
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1098 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1311 switch(scr->room)
18089 {
18090 case rSP_ITEM:
18091 case rGRUMBLE:
18092 case rBOMBS:
18093 case rARROWS:
18094 case rSWINDLE:
18095 case rMUPGRADE:
18096 case rLEARNSLASH:
18097 case rTAKEONE:
18098
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 61 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18099 55 Guy=0;
18100
18101 179 break;
18102
18103 case rREPAIR:
18104 if (get_qr(qr_OLD_DOORREPAIR)) break;
18105 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18106 Guy=0;
18107
18108 break;
18109 case rRP_HC:
18110 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18111 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18112 Guy=0;
18113
18114 break;
18115 case rMONEY:
18116
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18117 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18118 Guy=0;
18119
18120 break;
18121
18122 case rTRIFORCE:
18123 {
18124 45 int32_t tc = TriforceCount();
18125
18126
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18127 {
18128
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18129 10 Guy=0;
18130 9 }
18131 else
18132 {
18133
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18134 33 Guy=0;
18135 }
18136 }
18137 43 break;
18138 }
18139
18140
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1202 times.
1309 if(Guy)
18141 {
18142
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1169 times.
1202 if(ffire)
18143 1169 blockpath=true;
18144
18145
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 790 times.
1202 if(screen<128)
18146 790 sfx(WAV_SCALE);
18147
18148
6/6
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 117 times.
✓ Branch 5 taken 357 times.
2404 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18149 1202 Hero.Freeze();
18150 1202 }
18151 1309 }
18152
5/6
✓ Branch 0 taken 33908 times.
✓ Branch 1 taken 3472 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33837 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3472 times.
37380 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18153 {
18154 71 sfx(WAV_SCALE);
18155 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18156 71 }
18157
18158 116067 loaditem(scr, dx, dy);
18159
18160 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18161 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18162
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 38670 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
38689 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18163 {
18164
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18165 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18166 15 }
18167 38700 }
18168
18169 37458 void loadguys()
18170 {
18171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37458 times.
37458 if (loaded_guys)
18172 return;
18173
18174 37458 loaded_guys = true;
18175 37458 repaircharge = 0;
18176 37458 adjustmagic = false;
18177 37458 learnslash = false;
18178
2/2
✓ Branch 0 taken 112374 times.
✓ Branch 1 taken 37458 times.
149832 for (int32_t i=0; i<3; i++)
18179 {
18180 112374 prices[i] = 0;
18181 112374 }
18182
18183 76160 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18184 38702 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18185 38702 loadguys(scr);
18186 38702 });
18187 37458 }
18188
18189 38708 void loaditem(mapscr* scr, int offx, int offy)
18190 {
18191 38708 int screen = scr->screen;
18192 38708 byte Item = 0;
18193
18194
2/2
✓ Branch 0 taken 37802 times.
✓ Branch 1 taken 906 times.
38708 if(screen<128)
18195 {
18196 37802 Item=scr->item;
18197
18198
4/4
✓ Branch 0 taken 1730 times.
✓ Branch 1 taken 36072 times.
✓ Branch 2 taken 34306 times.
✓ Branch 3 taken 3496 times.
37802 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18199 {
18200
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 3410 times.
3496 if(scr->flags8&fSECRETITEM)
18201 86 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18202
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 2136 times.
3410 else if(scr->flags&fITEM)
18203 1274 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18204
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2020 times.
2136 else if(scr->flags11&efCARRYITEM)
18205 116 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18206 else
18207 {
18208 2020 int x = scr->itemx;
18209
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2005 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
2020 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18210 -170 :
18211 2020 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18212
3/6
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2020 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2020 times.
✗ Branch 5 not taken.
4040 add_item_for_screen(screen, new item(offx + x, offy + y,
18213
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2005 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2005 times.
✗ Branch 9 not taken.
2020 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18214
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 1908 times.
2020 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
18215 2020 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18216 }
18217 3496 }
18218 37802 }
18219
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18220 {
18221
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18222
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18223 {
18224 163 Item = special_warp_return_scr->catchall;
18225
18226
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18227 {
18228 162 int x = scr->itemx;
18229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18230 -170 :
18231 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18232
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18233
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18234 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18235 162 }
18236 163 }
18237 475 }
18238 38708 }
18239
18240 957 void never_return(int32_t screen, int32_t index)
18241 {
18242
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18243 191 goto doit;
18244
18245
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18246
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18247 {
18248 437 goto dontdoit;
18249 329 }
18250
18251 doit:
18252 520 setmapflag(get_scr(screen), mNEVERRET);
18253 dontdoit:
18254 957 return;
18255 }
18256
18257 67200 bool slowguy(int32_t id)
18258 {
18259
2/4
✓ Branch 0 taken 67200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67200 times.
67200 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18260 {
18261 return false;
18262 }
18263
18264 67200 id = id&0xFFF;
18265
18266
2/2
✓ Branch 0 taken 56866 times.
✓ Branch 1 taken 10334 times.
67200 switch(id)
18267 {
18268 case eOCTO1S:
18269 case eOCTO2S:
18270 case eOCTO1F:
18271 case eOCTO2F:
18272 case eLEV1:
18273 case eLEV2:
18274 case eROCK:
18275 case eBOULDER:
18276 10334 return true;
18277 }
18278
18279 56866 return false;
18280 67200 }
18281
18282 87075 static bool ok2add(mapscr* scr, int32_t id)
18283 {
18284
2/4
✓ Branch 0 taken 87075 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87075 times.
87075 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18285 {
18286 return false;
18287 }
18288
18289 87075 id = id&0xFFF;
18290
18291
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 86246 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
87075 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18292 464 return false;
18293
18294
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 85966 times.
✓ Branch 2 taken 380 times.
✓ Branch 3 taken 201 times.
86611 switch(guysbuf[id].type)
18295 {
18296 // I added a special case for shooters because having traps on the same screen
18297 // was preventing them from spawning due to TMPNORET. This means they will
18298 // never stay dead, though, so it may not be the best solution. - Saf
18299 case eePROJECTILE:
18300 380 return true;
18301
18302
18303 case eeDIG:
18304 {
18305
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18306 {
18307 case 1:
18308
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18309 79 return !getmapflag(scr, mTMPNORET);
18310
18311 47 return true;
18312
18313 75 case 0:
18314 default:
18315 75 return true;
18316 }
18317 }
18318 case eeGANON:
18319 case eeTRAP:
18320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].type == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18321
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].type == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18322 [[fallthrough]];
18323 default:
18324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85966 times.
85966 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18325 85966 break;
18326 }
18327
18328
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 64988 times.
85966 if(!get_qr(qr_NOTMPNORET))
18329 64988 return !getmapflag(scr, mTMPNORET);
18330
18331 20978 return true;
18332 87075 }
18333
18334 1668715 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18335 {
18336
3/4
✓ Branch 0 taken 289021 times.
✓ Branch 1 taken 1379694 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 289021 times.
1668715 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18337 {
18338 1379694 return;
18339 }
18340
18341 289021 int32_t ctype = rpos_handle.ctype();
18342
6/6
✓ Branch 0 taken 287513 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286198 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284985 times.
289021 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18343
18344 12108 auto [x, y] = rpos_handle.xy();
18345
18346 4036 int32_t cx=-1000, cy=-1000;
18347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18348 {
18349
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18350 {
18351 1508 cx=x+4;
18352 1508 cy=y+7;
18353 1508 }
18354
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18355 {
18356 1315 cx=x-8;
18357 1315 cy=y-1;
18358 1315 }
18359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18360 {
18361 1213 cx=x;
18362 1213 cy=y;
18363 1213 }
18364 4036 }
18365 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18366 {
18367 cx=x;
18368 cy=y;
18369 }
18370
18371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18372 {
18373
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18374 {
18375
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18376 {
18377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18378 4 return; // No point deleting it. A script might be toying with it in some way.
18379 else
18380 guys.del(j);
18381 }
18382 9750 }
18383
18384 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18385 4032 }
18386 1668715 }
18387
18388 35995 static void activate_fireball_statues(mapscr* scr)
18389 {
18390
2/2
✓ Branch 0 taken 34575 times.
✓ Branch 1 taken 1420 times.
35995 if (!(scr->flags11&efFIREBALLS))
18391 {
18392 34575 return;
18393 }
18394
18395 251340 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18396 249920 activate_fireball_statue(rpos_handle);
18397 249920 });
18398 35995 }
18399
18400 36678 void load_default_enemies(mapscr* scr)
18401 {
18402 36678 int screen = scr->screen;
18403 42143 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18404
18405 36678 wallm_load_clk=frame-80;
18406
18407
2/2
✓ Branch 0 taken 34782 times.
✓ Branch 1 taken 1896 times.
36678 if(scr->flags11&efZORA)
18408 {
18409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18410 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18411 1896 }
18412
18413
2/2
✓ Branch 0 taken 36500 times.
✓ Branch 1 taken 178 times.
36678 if(scr->flags11&efTRAP4)
18414 {
18415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18416 {
18417 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18418 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18419 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18420 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18421 178 }
18422 178 }
18423
18424 6492006 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18425 6455328 int32_t ctype = rpos_handle.ctype();
18426 6455328 int32_t cflag = rpos_handle.sflag();
18427 6455328 int32_t cflag_i = rpos_handle.cflag();
18428
18429
4/6
✓ Branch 0 taken 6455328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454958 times.
✓ Branch 3 taken 370 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454958 times.
6455328 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18430 {
18431 370 auto [x, y] = rpos_handle.xy();
18432
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 360 times.
370 if(trapLOSHorizontalID>=0)
18433 1080 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18434 370 }
18435
4/6
✓ Branch 0 taken 6454958 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454736 times.
✓ Branch 3 taken 222 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454736 times.
6454958 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18436 {
18437 222 auto [x, y] = rpos_handle.xy();
18438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(trapLOSVerticalID>=0)
18439 666 addenemy(screen, x, y, trapLOSVerticalID, -14);
18440 222 }
18441
4/6
✓ Branch 0 taken 6454736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454458 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454458 times.
6454736 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18442 {
18443 278 auto [x, y] = rpos_handle.xy();
18444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18445 {
18446
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18447 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18448 278 }
18449 278 }
18450
4/6
✓ Branch 0 taken 6454458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454022 times.
✓ Branch 3 taken 436 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454022 times.
6454458 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18451 {
18452 436 auto [x, y] = rpos_handle.xy();
18453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(trapConstantHorizontalID>=0)
18454 1308 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18455 436 }
18456
4/6
✓ Branch 0 taken 6454022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6453565 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6453565 times.
6454022 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18457 {
18458 457 auto [x, y] = rpos_handle.xy();
18459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(trapConstantVerticalID>=0)
18460 1371 addenemy(screen, x, y, trapConstantVerticalID, -14);
18461 457 }
18462
18463
1/2
✓ Branch 0 taken 6455328 times.
✗ Branch 1 not taken.
6455328 if(ctype==cSPINTILE1)
18464 {
18465 awaken_spinning_tile(rpos_handle);
18466 }
18467 6455328 });
18468
18469
2/2
✓ Branch 0 taken 36622 times.
✓ Branch 1 taken 56 times.
36678 if(scr->flags11&efTRAP2)
18470 {
18471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18472 {
18473
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18474 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18475
18476
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18477 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18478 56 }
18479 56 }
18480
18481
2/2
✓ Branch 0 taken 36595 times.
✓ Branch 1 taken 83 times.
36678 if(scr->flags11&efROCKS)
18482 {
18483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18484 {
18485 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18486 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18487 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18488 83 }
18489 83 }
18490 36678 }
18491
18492 #define SLOPE_STAGE_COMBOS 0
18493 #define SLOPE_STAGE_FFCS 1
18494 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18495
18496 22840025 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18497 {
18498
2/2
✓ Branch 0 taken 4658462 times.
✓ Branch 1 taken 18181563 times.
22840025 if (stage == SLOPE_STAGE_COMBOS)
18499 18181563 return (region_num_rpos*arg1)+arg2;
18500
2/2
✓ Branch 0 taken 4517266 times.
✓ Branch 1 taken 141196 times.
4658462 if (stage == SLOPE_STAGE_FFCS)
18501 4517266 return (region_num_rpos*7)+arg1;
18502
1/2
✓ Branch 0 taken 141196 times.
✗ Branch 1 not taken.
141196 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18503 141196 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18504 // TODO: what about FFCs from bordering screens?
18505
18506 assert(false);
18507 return 0;
18508 22840025 }
18509
18510 18181563 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18511 {
18512 18181563 mapscr* s = rpos_handle.scr;
18513 18181563 auto& cmb = rpos_handle.combo();
18514
18515 18181563 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18516 18181563 auto it = slopes.find(id);
18517
18518 18181563 bool wasSlope = it!=slopes.end();
18519 18181563 bool isSlope = cmb.type == cSLOPE;
18520
18521
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 18181427 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
18181563 if(isSlope && !wasSlope)
18522 {
18523 272 auto [x, y] = rpos_handle.xy();
18524 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18525 136 }
18526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18181427 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18181427 else if(wasSlope && !isSlope)
18527 {
18528 slopes.erase(it);
18529 }
18530 18181563 }
18531
18532 141196 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18533 {
18534 141196 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18535 141196 auto it = slopes.find(id);
18536
18537 141196 bool wasSlope = it!=slopes.end();
18538 141196 bool isSlope = is_slope;
18539
18540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 if(isSlope && !wasSlope)
18541 {
18542 static std::vector<word> TMP;
18543 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18544 TMP.resize(num_border_combos * 7 * 4);
18545
18546 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18547 TMP[tmp_index] = cid;
18548 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18549 }
18550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 else if(wasSlope && !isSlope)
18551 {
18552 slopes.erase(it);
18553 }
18554 141196 }
18555
18556 // Load a single column or row from a nearby screen, and load its slopes.
18557 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18558 {
18559 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18560
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18561 171 return;
18562
18563 3713 int offx = 0;
18564 3713 int offy = 0;
18565
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18566 913 offy = -16;
18567
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18568 862 offy = world_h;
18569
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18570 968 offx = -16;
18571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18572 970 offx = world_w;
18573
18574
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18575 {
18576 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18577
2/2
✓ Branch 0 taken 10526 times.
✓ Branch 1 taken 15465 times.
25991 if (!scr) continue;
18578
18579 10526 int slope_count = layer * (16*2);
18580
18581
4/4
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 2700 times.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 5082 times.
10526 if (dir == left || dir == right)
18582 {
18583 5444 int x = dir == left ? 15 : 0;
18584
2/2
✓ Branch 0 taken 59884 times.
✓ Branch 1 taken 5444 times.
65328 for (int y = 0; y < 11; y++)
18585 {
18586 59884 int pos = y * 16 + x;
18587 59884 int cid = scr->data[pos];
18588 59884 bool is_slope = combobuf[cid].type == cSLOPE;
18589
1/2
✓ Branch 0 taken 59884 times.
✗ Branch 1 not taken.
59884 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18590 59884 }
18591 5444 }
18592
3/4
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 2645 times.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
5082 else if (dir == up || dir == down)
18593 {
18594 5082 int y = dir == up ? 10 : 0;
18595
2/2
✓ Branch 0 taken 81312 times.
✓ Branch 1 taken 5082 times.
86394 for (int x = 0; x < 16; x++)
18596 {
18597 81312 int pos = y * 16 + x;
18598 81312 int cid = scr->data[pos];
18599 81312 bool is_slope = combobuf[cid].type == cSLOPE;
18600
1/2
✓ Branch 0 taken 81312 times.
✗ Branch 1 not taken.
81312 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18601 81312 }
18602 5082 }
18603
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15465 times.
✓ Branch 2 taken 10526 times.
25991 }
18604 3884 }
18605
18606 37530 void update_slope_comboposes()
18607 {
18608 16800298 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18609 16762768 update_slope_combopos(rpos_handle);
18610 16762768 });
18611
18612
2/2
✓ Branch 0 taken 36559 times.
✓ Branch 1 taken 971 times.
37530 if (Hero.sideview_mode())
18613 {
18614 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18615
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18616 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18617 971 });
18618 971 }
18619
18620 37530 update_slopes();
18621 37530 }
18622
18623 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18624 1418795 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18625 {
18626 1418795 delete_fireball_shooter(rpos_handle);
18627 1418795 }
18628
18629 //Placeholder in case we need it.
18630 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18631 {
18632 return;
18633 }
18634
18635 // Everything that must be done after we change a screen's combo to another combo. -L
18636 1418795 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18637 {
18638 1418795 rpos_handle.scr->valid |= mVALID;
18639 1418795 activate_fireball_statue(rpos_handle);
18640
18641
2/2
✓ Branch 0 taken 1418701 times.
✓ Branch 1 taken 94 times.
1418795 if(rpos_handle.ctype()==cSPINTILE1)
18642 {
18643 94 awaken_spinning_tile(rpos_handle);
18644 94 }
18645
18646 1418795 update_slope_combopos(rpos_handle);
18647 1418795 }
18648
18649 4517266 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18650 {
18651 4517266 ffcdata* ff = ffc_handle.ffc;
18652 4517266 auto& cmb = ffc_handle.combo();
18653
18654 4517266 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18655 4517266 auto it = slopes.find(id);
18656
18657 4517266 bool wasSlope = it!=slopes.end();
18658
1/2
✓ Branch 0 taken 4517266 times.
✗ Branch 1 not taken.
4517266 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18659
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4517266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4517266 if(isSlope && !wasSlope)
18660 {
18661 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18662 }
18663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4517266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4517266 else if(wasSlope && !isSlope)
18664 {
18665 slopes.erase(it);
18666 }
18667
18668 4517266 ffc_handle.scr->ffcCountMarkDirty();
18669 4517266 }
18670
18671 4414 void screen_combo_modify_pre(int32_t cid)
18672 {
18673 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18674
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18675 {
18676 5195 screen_combo_modify_preroutine(rpos_handle);
18677 5195 }
18678 2808608 });
18679 4414 }
18680 4414 void screen_combo_modify_post(int32_t cid)
18681 {
18682 4414 combo_caches::refresh(cid);
18683
18684 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18685
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18686 {
18687 5195 screen_combo_modify_postroutine(rpos_handle);
18688 5195 }
18689 2808608 });
18690
18691 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18692
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18693 {
18694 58 screen_ffc_modify_postroutine(ffc_handle);
18695 58 }
18696 139772 });
18697 4414 }
18698
18699 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18700 {
18701 94 int cid = rpos_handle.data();
18702 94 int cset = rpos_handle.cset();
18703 282 auto [x, y] = rpos_handle.xy();
18704
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18705 94 }
18706
18707 // It stands for next_side_pos
18708 // moves sle_x and sle_y to the next position
18709 11464 void nsp(bool random)
18710 {
18711
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18712 {
18713
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18714 {
18715 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18716 1634 sle_y = (zc_oldrand()%10)*16;
18717 1634 }
18718 else
18719 {
18720 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18721 1627 sle_x = (zc_oldrand()%15)*16;
18722 }
18723
18724 3261 return;
18725 }
18726
18727
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18728 {
18729
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18730 1855 sle_y+=16;
18731 else
18732 180 sle_x+=16;
18733 2035 }
18734
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18735 {
18736
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18737 2430 sle_x+=16;
18738 else
18739 166 sle_y-=16;
18740 2596 }
18741
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18742 {
18743
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18744 1404 sle_y-=16;
18745 else
18746 148 sle_x-=16;
18747 1552 }
18748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18749 {
18750
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18751 2020 sle_x-=16;
18752 else
18753 sle_y+=16;
18754 2020 }
18755 11464 }
18756
18757 // moves sle_x and sle_y to the next available position
18758 // returns the direction the enemy should face
18759 2429 int32_t next_side_pos(int32_t screen, bool random)
18760 {
18761 bool blocked;
18762 2429 int32_t c=0;
18763 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18764
18765 2429 do
18766 {
18767
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18768 22928 int x = sle_x + offx;
18769 22928 int y = sle_y + offy;
18770
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18771
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18772
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18773
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18774 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18775
18776
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18777 1 return -1;
18778
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18779 11463 while(blocked);
18780
18781 2428 int32_t dir=0;
18782
18783
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18784
18785
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18786
18787
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18788
18789
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18790
18791 2428 return dir;
18792 2429 }
18793
18794 bool can_side_load(int32_t id)
18795 {
18796 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18797 {
18798 return false;
18799 }
18800
18801 id = id&0xFFF;
18802
18803 switch(guysbuf[id].type)
18804 {
18805 case eeTEK:
18806 case eeLEV:
18807 case eeAQUA:
18808 case eeDONGO:
18809 case eeMANHAN:
18810 case eeGLEEOK:
18811 case eeDIG:
18812 case eeGHOMA:
18813 case eeLANM:
18814 case eePATRA:
18815 case eeGANON:
18816 case eePROJECTILE:
18817 return false;
18818 break;
18819 }
18820
18821 return true;
18822 }
18823
18824 bool enemy_spawning_has_checked_been_here;
18825 static bool enemy_spawning_has_been_here;
18826
18827 36678 static bool check_if_recently_visited()
18828 {
18829
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 36156 times.
36678 if (enemy_spawning_has_checked_been_here)
18830 522 return enemy_spawning_has_been_here;
18831
18832 36156 int mi = mapind(cur_map, cur_screen);
18833
18834 36156 enemy_spawning_has_been_here = false;
18835
2/2
✓ Branch 0 taken 216936 times.
✓ Branch 1 taken 36156 times.
253092 for (int i = 0; i < 6; i++)
18836
2/2
✓ Branch 0 taken 206777 times.
✓ Branch 1 taken 10159 times.
227095 if (visited[i] == mi)
18837 10159 enemy_spawning_has_been_here = true;
18838
18839
2/2
✓ Branch 0 taken 10159 times.
✓ Branch 1 taken 25997 times.
36156 if (!enemy_spawning_has_been_here)
18840 {
18841 25997 visited[vhead] = mi; //If not, it adds it to the array,
18842 25997 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18843 25997 }
18844
18845 36156 enemy_spawning_has_checked_been_here = true;
18846 36156 return enemy_spawning_has_been_here;
18847 36678 }
18848
18849 static std::array<bool, MAPSCRS> script_sle;
18850
18851 static int32_t sle_pattern = 0;
18852 static void script_side_load_enemies(mapscr* scr)
18853 {
18854 if (script_sle[scr->screen] || sle_clk) return;
18855
18856 sle_cnt = 0;
18857 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18858 ++sle_cnt;
18859 script_sle[scr->screen] = true;
18860 sle_pattern = scr->pattern;
18861 sle_clk = 0;
18862 }
18863
18864 54516 static void side_load_enemies(mapscr* scr)
18865 {
18866 54516 int screen = scr->screen;
18867
18868
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18869 {
18870 683 sle_pattern = scr->pattern;
18871 683 sle_cnt = 0;
18872 683 int32_t guycnt = 0;
18873
18874 683 int mi = mapind(cur_map, screen);
18875 683 bool reload=true;
18876 683 bool unbeatablereload = true;
18877
18878 683 load_default_enemies(scr);
18879
18880 683 bool beenhere = check_if_recently_visited();
18881
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18882 {
18883 42 sle_cnt=0;
18884 42 reload=false;
18885 42 }
18886
18887
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18888 {
18889 641 sle_cnt = game->guys[mi];
18890
18891
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18892 641 || sle_cnt==0)
18893 {
18894
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18895 1054 ++sle_cnt;
18896 221 }
18897
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18898 {
18899 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18900 {
18901 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18902 {
18903 unbeatablereload = false;
18904 }
18905 }
18906 if (unbeatablereload)
18907 {
18908 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18909 {
18910 ++sle_cnt;
18911 }
18912 }
18913 }
18914 641 }
18915
18916
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18917 {
18918 31 sle_cnt = 0;
18919
18920
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18921 108 ++sle_cnt;
18922 31 }
18923
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18924 sle_cnt = 0;
18925
18926
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18927 2446 ++guycnt;
18928
18929 683 game->guys[mi] = guycnt;
18930 683 }
18931
18932
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18933 {
18934 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18935 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18936
18937
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18938 {
18939 234 return;
18940 }
18941
18942 2195 int32_t enemy_slot=guys.Count();
18943
18944
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18945 sle_cnt--;
18946
18947
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18948 {
18949
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18950 {
18951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->type != eeTEK)
18952 {
18953 2195 guys.spr(enemy_slot)->dir = dir;
18954 2195 }
18955
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18956 {
18957 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18958 {
18959 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18960 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18961 }
18962 }
18963 2195 }
18964 2195 }
18965 2195 }
18966
18967
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18968 {
18969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18970 script_sle[screen] = false;
18971 else
18972 {
18973 578 get_screen_state(screen).loaded_enemies = true;
18974 }
18975 578 sle_clk = 0;
18976 578 }
18977 54516 }
18978
18979 1271103 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18980 {
18981
2/2
✓ Branch 0 taken 117220 times.
✓ Branch 1 taken 1153883 times.
1271103 if (!is_in_scrolling_region())
18982
2/4
✓ Branch 0 taken 1153883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1153883 times.
1153883 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18983 {
18984 return false; //never 0, never OoB.
18985 }
18986 // No corner enemies
18987
6/6
✓ Branch 0 taken 1098758 times.
✓ Branch 1 taken 172345 times.
✓ Branch 2 taken 41603 times.
✓ Branch 3 taken 1140361 times.
✓ Branch 4 taken 118860 times.
✓ Branch 5 taken 95088 times.
1271103 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
18988 213948 return false;
18989
18990 //Is a no spawn combo...
18991
4/4
✓ Branch 0 taken 1140351 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1140349 times.
1140361 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
18992 12 return false;
18993
18994 // No enemies in dungeon walls
18995
2/2
✓ Branch 0 taken 485260 times.
✓ Branch 1 taken 655089 times.
1140349 if (isdungeon(scr->screen))
18996 {
18997 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
18998
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
18999 319264 return false;
19000 335825 }
19001
19002 // Too close to hero
19003
4/4
✓ Branch 0 taken 78297 times.
✓ Branch 1 taken 742788 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 78157 times.
821085 if(tooclose(x,y,40) && t<11)
19004 78157 return false;
19005
19006 // Can't fly onto it?
19007
4/4
✓ Branch 0 taken 144461 times.
✓ Branch 1 taken 598467 times.
✓ Branch 2 taken 36074 times.
✓ Branch 3 taken 25255 times.
804257 if(isflier(scr->enemy[i])&&
19008
2/2
✓ Branch 0 taken 140466 times.
✓ Branch 1 taken 3995 times.
144461 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19009
2/2
✓ Branch 0 taken 61329 times.
✓ Branch 1 taken 79137 times.
140466 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19010 29250 return false;
19011
19012 // Can't jump onto it?
19013 if
19014 (
19015
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88795 times.
802477 guysbuf[scr->enemy[i]].type==eeTEK
19016
19017
2/2
✓ Branch 0 taken 88813 times.
✓ Branch 1 taken 624865 times.
713678 &&
19018 (
19019
2/2
✓ Branch 0 taken 88806 times.
✓ Branch 1 taken 7 times.
88813 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19020
2/2
✓ Branch 0 taken 88805 times.
✓ Branch 1 taken 1 times.
88806 COMBOTYPE(x+8,y+8)==cNOENEMY||
19021
1/2
✓ Branch 0 taken 88805 times.
✗ Branch 1 not taken.
88805 ispitfall(x+8,y+8)||
19022
2/2
✓ Branch 0 taken 88799 times.
✓ Branch 1 taken 6 times.
88805 MAPFLAG(x+8,y+8)==mfNOENEMY||
19023 88799 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19024 )
19025 )
19026 {
19027 18 return false;
19028 }
19029
19030 // Other off-limit combos
19031
6/6
✓ Branch 0 taken 598451 times.
✓ Branch 1 taken 115209 times.
✓ Branch 2 taken 509656 times.
✓ Branch 3 taken 88795 times.
✓ Branch 4 taken 280088 times.
✓ Branch 5 taken 229568 times.
1223316 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].type!=eeTEK &&
19032
2/2
✓ Branch 0 taken 287854 times.
✓ Branch 1 taken 221802 times.
509656 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19033 509656 guysbuf[scr->enemy[i]].type!=eeZORA)
19034 229568 return false;
19035
19036 // Don't ever generate enemies on these combos!
19037
4/4
✓ Branch 0 taken 483786 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 483792 times.
484092 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19038 312 return false;
19039
19040 //BS Dodongos need at least 2 spaces.
19041
4/4
✓ Branch 0 taken 1045 times.
✓ Branch 1 taken 482747 times.
✓ Branch 2 taken 1020 times.
✓ Branch 3 taken 25 times.
483792 if ((guysbuf[scr->enemy[i]].type==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19042 {
19043
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19044
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19045
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19046 ((y>144)||_walkflag(x, y+24,2)))
19047 {
19048 return false;
19049 }
19050 19 }
19051
19052 483786 return true;
19053 1164131 }
19054
19055 168020 bool is_ceiling_pattern(int32_t i)
19056 {
19057
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 167798 times.
168020 return (i==pCEILING || i==pCEILINGR);
19058 }
19059
19060 6001 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19061 {
19062 6001 std::vector<rpos_t> freeposcache;
19063
19064
2/2
✓ Branch 0 taken 66011 times.
✓ Branch 1 taken 6001 times.
72012 for(int32_t y=offy; y<offy+176; y+=16)
19065 {
19066
2/2
✓ Branch 0 taken 1056176 times.
✓ Branch 1 taken 66011 times.
1122187 for(int32_t x=offx; x<offx+256; x+=16)
19067 {
19068
3/4
✓ Branch 0 taken 1056176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422575 times.
✓ Branch 3 taken 633601 times.
1056176 if(is_starting_pos(scr,i,x,y,0))
19069 {
19070
2/4
✓ Branch 0 taken 422575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422575 times.
✗ Branch 3 not taken.
422575 freeposcache.push_back(COMBOPOS_REGION(x, y));
19071 422575 }
19072 1056176 }
19073 66011 }
19074
19075
2/2
✓ Branch 0 taken 5989 times.
✓ Branch 1 taken 12 times.
6001 if (!freeposcache.empty())
19076
1/2
✓ Branch 0 taken 5989 times.
✗ Branch 1 not taken.
5989 return freeposcache[zc_oldrand()%freeposcache.size()];
19077
19078 12 return rpos_t::None;
19079 6001 }
19080
19081 84843 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19082 {
19083 84843 int screen = scr->screen;
19084 84843 int x = 0;
19085 84843 int y = 0;
19086 84843 bool placed=false;
19087 84843 int32_t t=-1;
19088
19089 // First: enemy combo flags
19090
2/2
✓ Branch 0 taken 844917 times.
✓ Branch 1 taken 67212 times.
912129 for(int32_t sy=0; sy<176; sy+=16)
19091 {
19092
2/2
✓ Branch 0 taken 13387597 times.
✓ Branch 1 taken 827286 times.
14214883 for(int32_t sx=0; sx<256; sx+=16)
19093 {
19094 13387597 x = offx + sx;
19095 13387597 y = offy + sy;
19096 13387597 int32_t cflag = MAPFLAG(x, y);
19097 13387597 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19098
19099
2/4
✓ Branch 0 taken 13387597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13387597 times.
✗ Branch 3 not taken.
13387597 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19100 {
19101 if(!ok2add(scr, scr->enemy[i]))
19102 {
19103 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19104 }
19105 else
19106 {
19107 addenemy_z(screen,x,
19108 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19109 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19110
19111 ++guycnt;
19112
19113 placed=true;
19114 goto placed_enemy;
19115 }
19116 }
19117
19118
4/4
✓ Branch 0 taken 13369917 times.
✓ Branch 1 taken 17680 times.
✓ Branch 2 taken 13369917 times.
✓ Branch 3 taken 17680 times.
13387597 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19119 {
19120
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17631 times.
17680 if(!ok2add(scr, scr->enemy[i]))
19121 {
19122
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19123 49 }
19124 else
19125 {
19126 35262 addenemy_z(screen,x,
19127
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17630 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17631 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19128
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17631 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19129
19130 17631 ++guycnt;
19131
19132 17631 placed=true;
19133 17631 goto placed_enemy;
19134 }
19135 49 }
19136 13369966 }
19137 827286 }
19138
19139 // Next: enemy pattern
19140
6/8
✓ Branch 0 taken 5098 times.
✓ Branch 1 taken 62114 times.
✓ Branch 2 taken 61478 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 61478 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 61478 times.
67212 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19141 {
19142 61478 do
19143 {
19144
19145 // NES positions
19146 108222 pos%=9;
19147 108222 x=offx+stx[loadside][pos];
19148 108222 y=offy+sty[loadside][pos];
19149 108222 ++pos;
19150 108222 ++t;
19151
2/2
✓ Branch 0 taken 46744 times.
✓ Branch 1 taken 61478 times.
169700 }
19152
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 107955 times.
108222 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19153 61478 }
19154
19155
4/4
✓ Branch 0 taken 61478 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 267 times.
✓ Branch 3 taken 61211 times.
67212 if(t<0 || t >= 20) // above enemy pattern failed
19156 {
19157 // Final chance: find a random position anywhere onscreen
19158 6001 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19159
19160
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5989 times.
6001 if (rand_rpos != rpos_t::None)
19161 {
19162 5989 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19163 5989 }
19164 else // All opportunities failed - abort
19165 {
19166 12 return;
19167 }
19168 5989 }
19169
19170 {
19171 67200 int32_t c=0;
19172 67200 c=clk;
19173
19174
2/2
✓ Branch 0 taken 10334 times.
✓ Branch 1 taken 56866 times.
67200 if(!slowguy(scr->enemy[i]))
19175 56866 ++fastguys;
19176
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 8566 times.
10334 else if(fastguys>0)
19177 1768 c=-15*(i-fastguys+2);
19178 else
19179 8566 c=-15*(i+1);
19180
19181
4/6
✓ Branch 0 taken 32607 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 32607 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32607 times.
67200 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19182 {
19183 // Special case for blue leevers
19184
4/4
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 30243 times.
✓ Branch 2 taken 1189 times.
✓ Branch 3 taken 1175 times.
32607 if(guysbuf[scr->enemy[i]].type==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19185 1189 c=-15*(i+1);
19186 else
19187 31418 c=-15;
19188 32607 }
19189
19190
2/2
✓ Branch 0 taken 66379 times.
✓ Branch 1 taken 821 times.
67200 if(!ok2add(scr, scr->enemy[i]))
19191 {
19192
4/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 685 times.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 136 times.
821 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19193 821 }
19194 else
19195 {
19196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66379 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66379 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19197 {
19198
3/4
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 66102 times.
✓ Branch 2 taken 277 times.
✗ Branch 3 not taken.
132758 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19199
3/4
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 66102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 277 times.
66379 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19200
19201 66379 ++guycnt;
19202 66379 }
19203 }
19204
19205 67200 placed=true;
19206 67200 } // if(t < 20)
19207
19208 placed_enemy:
19209
19210 // I don't like this, but it seems to work...
19211 static bool foundCarrier;
19212
19213
2/2
✓ Branch 0 taken 62100 times.
✓ Branch 1 taken 22731 times.
84831 if(i==0)
19214 22731 foundCarrier=false;
19215
19216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84831 times.
84831 if(placed)
19217 {
19218
4/4
✓ Branch 0 taken 22731 times.
✓ Branch 1 taken 62100 times.
✓ Branch 2 taken 22550 times.
✓ Branch 3 taken 181 times.
84831 if(i==0 && scr->flags11&efLEADER)
19219 {
19220 181 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19221
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 7 times.
181 if (e)
19222 {
19223 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
174 if ((e->type == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19225 {
19226 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19227 }
19228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if (e)
19229 {
19230 174 e->leader = true;
19231 174 }
19232 174 }
19233 181 }
19234
19235 84831 ScreenItemState item_state = get_screen_state(screen).item_state;
19236
5/6
✓ Branch 0 taken 84587 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 84587 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 84503 times.
84831 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19237 {
19238 84 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19239
2/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
84 if (e && (e->flags&guy_doesnt_count)==0)
19240 {
19241 84 e->itemguy = true;
19242 84 foundCarrier=true;
19243 84 }
19244 84 }
19245 84831 }
19246 84843 }
19247
19248 // returns index of first sprite with matching id, -1 if none found
19249 265 enemy* find_guy_first_for_id(int screen, int id, int mask)
19250 {
19251 265 int count = guys.Count();
19252
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 7 times.
392 for (int32_t i=0; i<count; i++)
19253 {
19254 385 enemy* e = (enemy*)guys.spr(i);
19255
4/4
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 79 times.
385 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19256 {
19257 258 return e;
19258 }
19259 127 }
19260
19261 7 return nullptr;
19262 265 }
19263
19264 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19265 {
19266 int count = guys.Count();
19267 for(int32_t i=0; i<count; i++)
19268 {
19269 enemy* e = (enemy*)guys.spr(i);
19270 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19271 {
19272 if (n > 1) --n;
19273 else return e;
19274 }
19275 }
19276 return nullptr;
19277 }
19278
19279 14 bool scriptloadenemies(int screen)
19280 {
19281 // https://discord.com/channels/876899628556091432/1395904851908755577
19282
5/14
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
28 bool replay_compat_enemies_load_bug = replay_is_active() && replay_get_meta_bool("compat_scriptloadenemies");
19283 14 auto& state = get_screen_state(screen);
19284
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_compat_enemies_load_bug)
19285 state.loaded_enemies = true;
19286
19287
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (sle_clk || script_sle[screen]) return false;
19288
19289 14 mapscr* scr = get_scr(screen);
19290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(scr->pattern==pNOSPAWN) return false;
19291
19292
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19293 {
19294 script_side_load_enemies(scr);
19295 return true;
19296 }
19297
19298 184 auto [x, y] = translate_screen_coordinates_to_world(screen);
19299 14 int32_t pos=zc_oldrand()%9;
19300 14 int32_t clk=-15,fastguys=0;
19301 14 int32_t i=0,guycnt=0;
19302 14 int32_t loadcnt = 10;
19303
19304
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 14 times.
99 for(; i<loadcnt && scr->enemy[i]>0; i++)
19305 {
19306 85 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19307 255 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (guys.Count() > preguycount)
19309 {
19310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19311 {
19312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19313 {
19314 85 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19315 85 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19316 85 }
19317 85 }
19318 85 }
19319 85 --clk;
19320 85 }
19321 14 return true;
19322 14 }
19323
19324 14792276 void loadenemies()
19325 {
19326 29964710 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19327 15172434 int screen = scr->screen;
19328 15172434 auto& state = get_screen_state(screen);
19329
2/2
✓ Branch 0 taken 14755572 times.
✓ Branch 1 taken 416862 times.
15172434 if (state.loaded_enemies)
19330 14755572 return;
19331
19332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416862 times.
416862 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19333 {
19334 state.loaded_enemies = true;
19335 return;
19336 }
19337
19338 // dungeon basements
19339 static byte dngn_enemy_x[4] = {32,96,144,208};
19340
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 267898 times.
416862 if (cur_screen>=128)
19341 {
19342
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19344 {
19345 for(int32_t i=0; i<10; i++)
19346 {
19347 if ( scr->enemy[i] )
19348 {
19349 int32_t preguycount = guys.Count();
19350 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19351 if (guys.Count() > preguycount)
19352 {
19353 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19354 {
19355 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19356 {
19357 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19358 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19359 }
19360 }
19361 }
19362 }
19363 }
19364 }
19365 else
19366 {
19367
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19368 {
19369 1900 int32_t preguycount = guys.Count();
19370
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19372 {
19373
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19374 {
19375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19376 {
19377 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19378 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19379 4 }
19380 4 }
19381 1900 }
19382 1900 }
19383 }
19384
19385 475 state.loaded_enemies = true;
19386 475 return;
19387 }
19388
19389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267898 times.
267898 if (scr->pattern == pNOSPAWN)
19390 return;
19391
19392 // TODO: configure when screen enemies spawn.
19393
2/2
✓ Branch 0 taken 90606 times.
✓ Branch 1 taken 177292 times.
267898 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19394 177292 return;
19395
19396
4/4
✓ Branch 0 taken 52159 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 36090 times.
90606 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19397 {
19398 54516 side_load_enemies(scr);
19399 54516 return;
19400 }
19401
19402 36090 state.loaded_enemies = true;
19403
19404 // check if it's the dungeon boss and it has been beaten before
19405
4/4
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 35712 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 95 times.
36090 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&(1 << li_boss_killed))
19406 95 return;
19407
19408 35995 int32_t loadcnt = 10;
19409 35995 int16_t mi = mapind(cur_map, screen);
19410 35995 bool beenhere = check_if_recently_visited();
19411
19412 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19413 35995 bool reload = true;
19414
4/4
✓ Branch 0 taken 10302 times.
✓ Branch 1 taken 25693 times.
✓ Branch 2 taken 5031 times.
✓ Branch 3 taken 5271 times.
35995 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19415 {
19416 5271 loadcnt = 0; //It will tell it not to load any enemies,
19417 5271 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19418 5271 }
19419
19420 35995 bool unbeatablereload = true;
19421
2/2
✓ Branch 0 taken 5271 times.
✓ Branch 1 taken 30724 times.
35995 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19422 {
19423 30724 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19424
19425
2/4
✓ Branch 0 taken 11007 times.
✓ Branch 1 taken 19717 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30724 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11007 times.
11007 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19427 19717 loadcnt = 10; //That means all enemies need to be respawned.
19428
3/4
✓ Branch 0 taken 25693 times.
✓ Branch 1 taken 5031 times.
✓ Branch 2 taken 25693 times.
✗ Branch 3 not taken.
30724 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19429 {
19430 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19431 {
19432 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19433 {
19434 unbeatablereload = false;
19435 }
19436 }
19437 if (unbeatablereload)
19438 {
19439 loadcnt = 10;
19440 }
19441 }
19442 30724 }
19443
19444
4/4
✓ Branch 0 taken 34534 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 212 times.
✓ Branch 3 taken 34322 times.
35995 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19445 1673 loadcnt = 10; //All enemies also need to be respawned.
19446
19447 // do enemies that are always loaded
19448 35995 load_default_enemies(scr);
19449 35995 activate_fireball_statues(scr);
19450
19451 35995 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19452 35995 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19453 35995 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19454
4/4
✓ Branch 0 taken 16124 times.
✓ Branch 1 taken 104629 times.
✓ Branch 2 taken 84758 times.
✓ Branch 3 taken 35995 times.
120753 for(; i<loadcnt && scr->enemy[i]>0; i++)
19455 {
19456 84758 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19457 84758 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19458
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 83925 times.
84758 if (guys.Count() > preguycount)
19459 {
19460
2/2
✓ Branch 0 taken 77968 times.
✓ Branch 1 taken 5957 times.
83925 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19461 {
19462
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5953 times.
5957 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19463 {
19464 5953 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19465 5953 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19466 5953 }
19467 5957 }
19468 83925 }
19469
19470 84758 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19471 84758 }
19472
19473 35995 game->guys[mi] = guycnt;
19474 15172434 });
19475 14792276 }
19476
19477 233 void moneysign()
19478 {
19479 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19480 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19481 233 set_clip_state(pricesdisplaybuf, 0);
19482 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19483 233 }
19484
19485 3412 void putprices(bool sign)
19486 {
19487
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3380 times.
3412 if(fadeclk > 0) return;
19488
19489 3380 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19490 3380 int32_t step=32;
19491 3380 int32_t x=80;
19492
19493
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 3099 times.
3380 if(prices[2]==0)
19494 {
19495 3099 step<<=1;
19496
19497
2/2
✓ Branch 0 taken 3067 times.
✓ Branch 1 taken 32 times.
3099 if(prices[1]==0)
19498 {
19499 3067 x=112;
19500 3067 }
19501 3099 }
19502
19503
2/2
✓ Branch 0 taken 3380 times.
✓ Branch 1 taken 10140 times.
13520 for(int32_t i=0; i<3; i++)
19504 {
19505 // Kind of stupid, but it works: 100000 is used to indicate that an item
19506 // has a price of zero rather than there being no item.
19507 // 100000 isn't a valid price, so this doesn't cause problems.
19508
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 9101 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
10140 if(prices[i]!=0 && prices[i]<100000)
19509 {
19510 char buf[8];
19511 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19512
19513 1039 int32_t l=(int32_t)strlen(buf);
19514 1039 set_clip_state(pricesdisplaybuf, 0);
19515
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19516 1039 }
19517
19518 10140 x+=step;
19519 10140 }
19520 3412 }
19521
19522 // Setting up special rooms
19523 // Also called when the Letter is used successfully.
19524 1217 void setupscreen()
19525 {
19526 1217 boughtsomething=false;
19527
19528 // Either the origin screen, or if in a 0x80 room the screen player came from.
19529
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 801 times.
1217 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19530 1217 mapscr* scr = origin_scr;
19531
19532 1217 word str=base_scr->str;
19533
19534 2269 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19535
19536 // Prices are already set to 0 in dowarp()
19537
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1217 switch(base_scr->room)
19538 {
19539 case rSP_ITEM: // special item
19540 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19541 164 break;
19542
19543 case rINFO: // pay for info
19544 {
19545 28 int32_t count = 0;
19546 28 int32_t base = 88;
19547 28 int32_t step = 5;
19548
19549 28 moneysign();
19550
19551
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19552 {
19553
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19554 {
19555 84 ++count;
19556 84 }
19557 else
19558 break;
19559 84 }
19560
19561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19562 {
19563
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19564 {
19565 base = 88+32;
19566 }
19567
19568
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19569 {
19570 step = 6;
19571 }
19572
19573
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19574 {
19575 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19576 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19577 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19578
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19579 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19580 84 int32_t itemid = current_item_id(itype_wealthmedal);
19581
19582
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19583 {
19584 if(itemsbuf[itemid].flags & item_flag1)
19585 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19586 else
19587 prices[i]-=itemsbuf[itemid].misc1;
19588 prices[i]=vbound(prices[i], -99999, 0);
19589 if(prices[i]==0)
19590 prices[i]=100000;
19591 }
19592
19593
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19594 prices[i]=-1;
19595 84 }
19596 28 }
19597
19598 28 break;
19599 }
19600
19601 case rMONEY: // secret money
19602 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19603 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19604 44 break;
19605
19606 case rGAMBLE: // gambling
19607 11 prices[0]=prices[1]=prices[2]=-10;
19608 11 moneysign();
19609 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19610 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19611 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19612 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19613 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19614 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19615 11 break;
19616
19617 case rREPAIR: // door repair
19618
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19619 // }
19620 13 repaircharge=base_scr->catchall;
19621 13 break;
19622
19623 case rMUPGRADE: // upgrade magic
19624 2 adjustmagic=true;
19625 2 break;
19626
19627 case rLEARNSLASH: // learn slash attack
19628 2 learnslash=true;
19629 2 break;
19630
19631 case rRP_HC: // heart container or red potion
19632 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19633 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19634 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19635 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19636 17 break;
19637
19638 case rP_SHOP: // potion shop
19639
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19640 {
19641 12 str=0;
19642 12 break;
19643 }
19644
19645 [[fallthrough]];
19646 case rTAKEONE: // take one
19647 case rSHOP: // shop
19648 {
19649 194 int32_t count = 0;
19650 194 int32_t base = 88;
19651 194 int32_t step = 5;
19652
19653
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19654 193 moneysign();
19655
19656 //count and align the stuff
19657
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19658 {
19659
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19660 {
19661 523 ++count;
19662 523 }
19663 else
19664 {
19665 37 break;
19666 }
19667 523 }
19668
19669
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19670 {
19671 22 base = 88+32;
19672 22 }
19673
19674
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19675 {
19676 15 step = 6;
19677 15 }
19678
19679
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19680 {
19681 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19682 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19683
19684
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19685 {
19686 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19687
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19688 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19689 521 int32_t itemid = current_item_id(itype_wealthmedal);
19690
19691
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19692 {
19693
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19694 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19695 else
19696 prices[i]+=itemsbuf[itemid].misc1;
19697 9 prices[i]=vbound(prices[i], 0, 99999);
19698
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19699 prices[i]=100000;
19700 9 }
19701
19702
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19703 prices[i]=1;
19704 521 }
19705 523 }
19706
19707 194 break;
19708 }
19709 case rBOTTLESHOP: // bottle shop
19710 {
19711 1 int32_t count = 0;
19712 1 int32_t base = 88;
19713 1 int32_t step = 5;
19714
19715 1 moneysign();
19716 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19717 //count and align the stuff
19718
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19719 {
19720
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19721 {
19722 3 ++count;
19723 3 }
19724 else
19725 {
19726 break;
19727 }
19728 3 }
19729
19730
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19731 {
19732 base = 88+32;
19733 }
19734
19735
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19736 {
19737 step = 6;
19738 }
19739
19740
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19741 {
19742 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19743 //{ Setup dummy item
19744 3 item* curItem = ((item*)items.spr(items.Count()-1));
19745 3 curItem->PriceIndex = i;
19746 3 newcombo const& cmb = combobuf[bst.comb[i]];
19747
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19748 {
19749 curItem->yofs = -32768;
19750 }
19751 3 curItem->o_tile = cmb.o_tile;
19752 3 curItem->o_cset = bst.cset[i];
19753 3 curItem->cs = curItem->o_cset;
19754 3 curItem->tile = cmb.o_tile;
19755 3 curItem->o_speed = cmb.speed;
19756 3 curItem->o_delay = 0;
19757 3 curItem->frames = cmb.frames;
19758 3 curItem->flip = cmb.flip;
19759 3 curItem->type = itype_bottlefill; //no pickup w/o empty bottle
19760 3 curItem->pstring = 0;
19761 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19762 3 curItem->flash = false;
19763 3 curItem->twohand = false;
19764 3 curItem->anim = true;
19765 3 curItem->hit_width=1;
19766 3 curItem->hyofs=4;
19767 3 curItem->hit_height=12;
19768 3 curItem->script=0;
19769 3 curItem->txsz=1;
19770 3 curItem->tysz=1;
19771 //}
19772
19773 3 prices[i] = bst.price[i];
19774
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19775 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19776 3 int32_t itemid = current_item_id(itype_wealthmedal);
19777
19778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19779 {
19780 if(itemsbuf[itemid].flags & item_flag1)
19781 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19782 else
19783 prices[i]+=itemsbuf[itemid].misc1;
19784 prices[i]=vbound(prices[i], 0, 99999);
19785 if(prices[i]==0)
19786 prices[i]=100000;
19787 }
19788
19789
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19790 prices[i]=1;
19791 3 }
19792
19793 1 break;
19794 }
19795
19796 case rBOMBS: // more bombs
19797 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19798 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19799 19 prices[0]=-base_scr->catchall;
19800 19 break;
19801
19802 case rARROWS: // more arrows
19803 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19804 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19805 prices[0]=-base_scr->catchall;
19806 break;
19807
19808 case rSWINDLE: // leave heart container or money
19809 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19810 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19811 14 prices[0]=-1;
19812 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19813 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19814 14 prices[1]=-base_scr->catchall;
19815 14 break;
19816
19817 }
19818
19819
3/4
✓ Branch 0 taken 1198 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1198 times.
1217 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19820 {
19821 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19822 19 int32_t itemid = current_item_id(itype_wealthmedal);
19823
19824
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19825 {
19826 if(itemsbuf[itemid].flags & item_flag1)
19827 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19828 else
19829 prices[i]+=itemsbuf[itemid].misc1;
19830 }
19831
19832
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19833 prices[i]=-1;
19834 19 }
19835
19836 1217 putprices(false);
19837
19838
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 59 times.
1217 if(str)
19839 {
19840 1158 donewmsg(base_scr, str);
19841 1158 }
19842 else
19843 {
19844 59 Hero.unfreeze();
19845 }
19846 1217 }
19847
19848 enum
19849 {
19850 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19851 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19852
19853 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19854
19855 MNU_DATA_MAX
19856 };
19857 struct menu_choice
19858 {
19859 int32_t x, y;
19860 int32_t pos;
19861 int32_t upos, dpos, lpos, rpos;
19862 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19863 18 {}
19864 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19865 int32_t dpos, int32_t lpos, int32_t rpos)
19866 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19867 18 {}
19868 };
19869 static int32_t msg_menu_data[MNU_DATA_MAX];
19870 static bool do_run_menu = false;
19871 bool do_end_str = false;
19872 static bool wait_advance = false;
19873 427 static std::map<int32_t, menu_choice> menu_options;
19874 46315 void clr_msg_data()
19875 {
19876 46315 do_end_str = false;
19877 46315 wait_advance = false;
19878 46315 do_run_menu = false;
19879 46315 menu_options.clear();
19880 46315 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19881 46315 }
19882
19883 static char namebuf[9] = {0};
19884 static char* nameptr = NULL;
19885 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19886 2036 bool runMenuCursor()
19887 {
19888 2036 clear_bitmap(msg_menu_bmp_buf);
19889
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19890 {
19891 msg_menu_data[MNU_CHOSEN] = 0;
19892 return true; //end menu
19893 }
19894 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19895 //If the cursor is at an invalid pos, find the first pos >= 0...
19896
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19897 {
19898 pos = 0;
19899 while(menu_options.find(pos) == menu_options.end())
19900 ++pos;
19901 }
19902 2036 menu_choice* ch = &menu_options[pos];
19903
19904 2036 bool pressed = true;
19905
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19906
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19907
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19908
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19909 2010 else pressed = false;
19910
19911
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19912 26 msg_menu_data[MNU_TIMER] = 1;
19913
19914 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19915 2036 bool held = false;
19916
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19917 {
19918 90 held = true;
19919
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19923 89 else held = false;
19924 90 }
19925 //If the cursor is at an invalid pos, find the first pos >= 0...
19926
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19927 {
19928 pos = 0;
19929 while(menu_options.find(pos) == menu_options.end())
19930 ++pos;
19931 }
19932
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19933 27 sfx(MsgStrings[msgstr].sfx);
19934
19935 2036 ch = &menu_options[pos];
19936 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19937 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19938 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19939 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19940
19941 2036 msg_menu_data[MNU_CHOSEN] = pos;
19942
19943
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19944 {
19945 603 rAbtn(); //Eat
19946
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19947 603 }
19948
19949
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19950 //Eat inputs
19951 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19952
19953
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19954 5 menu_options.clear();
19955
19956 2036 return ret;
19957 //false if pos changed this frame; no confirming while moving the cursor!
19958 2036 }
19959
19960 920426 bool bottom_margin_clip()
19961 {
19962 1052695 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19963
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 132269 times.
920426 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19964 }
19965
19966 void update_msgstr();
19967
19968 3713 static bool parsemsgcode(const StringCommand& command)
19969 {
19970 3713 auto& args = command.args;
19971 3713 int last_arg = 0;
19972
19973
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 2064 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3713 switch (command.code)
19974 {
19975 case MSGC_NEWLINE:
19976 {
19977 1280 ssc_tile_hei = ssc_tile_hei_buf;
19978
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19979 1280 ssc_tile_hei_buf = -1;
19980 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19981 1280 cursor_x=msg_margins[left];
19982 1280 return true;
19983 }
19984
19985 case MSGC_COLOUR:
19986 {
19987 2064 int32_t cset = args[0];
19988 2064 msgcolour = CSET(cset)+(args[1]);
19989 2064 return true;
19990 }
19991
19992 case MSGC_SHDCOLOR:
19993 {
19994 int32_t cset = args[0];
19995 msg_shdcol = CSET(cset)+args[1];
19996 return true;
19997 }
19998 case MSGC_SHDTYPE:
19999 {
20000 msg_shdtype = args[0];
20001 return true;
20002 }
20003
20004 case MSGC_SPEED:
20005 {
20006 56 msgspeed=args[0];
20007 56 return true;
20008 }
20009
20010 case MSGC_CTRUP:
20011 {
20012 int32_t a1 = args[0];
20013 int32_t a2 = args[1];
20014 game->change_counter(a2, a1);
20015 return true;
20016 }
20017
20018 case MSGC_CTRDN:
20019 {
20020 5 int32_t a1 = args[0];
20021 5 int32_t a2 = args[1];
20022 5 game->change_counter(-a2, a1);
20023 5 return true;
20024 }
20025
20026 case MSGC_CTRSET:
20027 {
20028 7 int32_t a1 = args[0];
20029 7 int32_t a2 = args[1];
20030 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20031 7 return true;
20032 }
20033
20034 case MSGC_CTRUPPC:
20035 case MSGC_CTRDNPC:
20036 case MSGC_CTRSETPC:
20037 {
20038 2 int32_t counter = args[0];
20039 2 int32_t amount = args[1];
20040 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20041
20042
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20043 amount*=-1;
20044
20045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20046 game->set_counter(amount, counter);
20047 else
20048 2 game->change_counter(amount, counter);
20049
20050 2 return true;
20051 }
20052
20053 case MSGC_GIVEITEM:
20054 {
20055 70 int32_t itemID = args[0];
20056
20057 70 getitem(itemID, true);
20058
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20059 {
20060 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20061 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20062 70 }
20063 70 return true;
20064 }
20065
20066
20067 case MSGC_WARP:
20068 {
20069 int32_t dmap = args[0];
20070 int32_t scrn = args[1];
20071 int32_t dx = args[2];
20072 int32_t dy = args[3];
20073 int32_t wfx = args[4];
20074 int32_t sfx = args[5];
20075 if(dx >= MAX_SCC_ARG) dx = -1;
20076 if(dy >= MAX_SCC_ARG) dy = -1;
20077 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20078 do_end_str = true;
20079 return true;
20080 }
20081
20082 case MSGC_SETSCREEND:
20083 {
20084 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20085 int32_t screen = args[1];
20086 int32_t reg = args[2];
20087 int32_t val = args[3];
20088 FFCore.set_screen_d(screen + dmap, reg, val);
20089 return true;
20090 }
20091 case MSGC_TAKEITEM:
20092 {
20093 11 int32_t itemID = args[0];
20094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20095 {
20096 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20097 }
20098 11 takeitem(itemID);
20099
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20100 {
20101 game->forced_bwpn = -1;
20102 } //not else if! -Z
20103
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20104 {
20105 game->forced_awpn = -1;
20106 }
20107
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20108 {
20109 game->forced_xwpn = -1;
20110 } //not else if! -Z
20111
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20112 {
20113 game->forced_ywpn = -1;
20114 }
20115 11 verifyBothWeapons();
20116 11 return true;
20117 }
20118
20119 case MSGC_SFX:
20120 {
20121 22 sfx(args[0]);
20122 22 return true;
20123 }
20124
20125 case MSGC_MIDI:
20126 {
20127 7 int32_t music = args[0];
20128
20129
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20130 1 music_stop();
20131 else
20132 6 jukebox(music+(ZC_MIDI_COUNT-1));
20133
20134 7 return true;
20135 }
20136
20137 case MSGC_FONT:
20138 {
20139 int fontid = args[0];
20140 int oh = text_height(msgfont);
20141 msgfont = get_zc_font(fontid);
20142 int nh = text_height(msgfont);
20143 int mh = std::max(oh,nh);
20144 if(mh > ssc_tile_hei_buf)
20145 ssc_tile_hei_buf = mh;
20146 return true;
20147 }
20148 case MSGC_RUN_FRZ_GENSCR:
20149 {
20150 word scr_id = args[0];
20151 bool force_redraw = args[1]!=0;
20152 if(force_redraw)
20153 {
20154 update_msgstr();
20155 draw_screen();
20156 }
20157 FFCore.runGenericFrozenEngine(scr_id);
20158 return true;
20159 }
20160 case MSGC_DRAWTILE:
20161 {
20162 int32_t tl = args[0];
20163 int32_t cs = args[1];
20164 int32_t t_wid = args[2];
20165 int32_t t_hei = args[3];
20166 int32_t fl = args[4];
20167
20168 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20169 {
20170 ssc_tile_hei = ssc_tile_hei_buf;
20171 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20172 ssc_tile_hei_buf = -1;
20173 cursor_y += thei + MsgStrings[msgstr].vspace;
20174 if(bottom_margin_clip()) return true;
20175 cursor_x=msg_margins[left];
20176 }
20177
20178 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20179 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20180 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20181 return true;
20182 }
20183
20184 case MSGC_GOTOIFRAND:
20185 {
20186 1 int32_t odds = args[0];
20187
20188 1 last_arg = 1;
20189
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20190 1 goto switched;
20191
20192 return true;
20193 }
20194
20195 case MSGC_GOTOIFGLOBAL:
20196 {
20197 int32_t arg = args[0];
20198 int32_t d = zc_min(7,arg);
20199 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20200 arg = args[1];
20201
20202 if(game->screen_d[s][d] >= arg)
20203 {
20204 last_arg = 2;
20205 goto switched;
20206 }
20207
20208 return true;
20209 }
20210
20211 case MSGC_CHANGEPORTRAIT:
20212 {
20213 return true; //not implemented
20214 }
20215
20216 case MSGC_GOTOIFCREEND:
20217 {
20218 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20219 int32_t screen = args[1];
20220 int32_t reg = args[2];
20221 int32_t val = args[3];
20222 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20223 {
20224 last_arg = 4;
20225 goto switched;
20226 }
20227 return true;
20228 }
20229
20230 case MSGC_GOTOIF:
20231 {
20232 122 int32_t it = args[0];
20233
20234
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20235 {
20236 35 last_arg = 1;
20237 35 goto switched;
20238 }
20239
20240 87 return true;
20241 }
20242
20243 case MSGC_GOTOIFCTR:
20244 {
20245
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20246 {
20247 14 last_arg = 2;
20248 14 goto switched;
20249 }
20250
20251 14 return true;
20252 }
20253
20254 case MSGC_GOTOIFCTRPC:
20255 {
20256 int32_t counter = args[0];
20257 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20258
20259 if(game->get_counter(counter)>=amount)
20260 {
20261 last_arg = 2;
20262 goto switched;
20263 }
20264
20265 return true;
20266 }
20267
20268 case MSGC_GOTOIFTRICOUNT:
20269 {
20270 if(TriforceCount() >= args[0])
20271 {
20272 last_arg = 1;
20273 goto switched;
20274 }
20275
20276 return true;
20277 }
20278
20279 case MSGC_GOTOIFTRI:
20280 {
20281 int32_t lev = args[0];
20282
20283 if(lev<MAXLEVELS && game->lvlitems[lev]&(1 << li_mcguffin))
20284 {
20285 last_arg = 1;
20286 goto switched;
20287 }
20288
20289 return true;
20290 }
20291
20292 case MSGC_SETUPMENU:
20293 {
20294 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20295 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20296 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20297 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20298 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20299 5 return true;
20300 }
20301
20302 case MSGC_MENUCHOICE:
20303 {
20304 18 int32_t pos = args[0];
20305 18 int32_t upos = args[1];
20306 18 int32_t dpos = args[2];
20307 18 int32_t lpos = args[3];
20308 18 int32_t rpos = args[4];
20309
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20310 {
20311 2 ssc_tile_hei = ssc_tile_hei_buf;
20312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20313 2 ssc_tile_hei_buf = -1;
20314 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20316 2 cursor_x=msg_margins[left];
20317 2 }
20318
20319 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20320 18 upos, dpos, lpos, rpos);
20321
20322
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20323 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20324 18 return true;
20325 }
20326
20327 case MSGC_RUNMENU:
20328 {
20329 5 msg_menu_data[MNU_CHOSEN] = 0;
20330 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20332 return true;
20333 5 do_run_menu = true;
20334 5 return true;
20335 }
20336
20337 case MSGC_GOTOMENUCHOICE:
20338 {
20339 7 int32_t choice = args[0];
20340
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20341 {
20342 5 last_arg = 1;
20343 5 goto switched;
20344 }
20345
20346 2 return true;
20347 }
20348
20349 case MSGC_ENDSTRING:
20350 {
20351 3 do_end_str = true;
20352 3 return true;
20353 }
20354 case MSGC_WAIT_ADVANCE:
20355 {
20356 wait_advance = true;
20357 linkedmsgclk = 51;
20358 return true;
20359 }
20360 case MSGC_TRIGSECRETS:
20361 {
20362 bool perm = args[0];
20363 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20364 if(perm)
20365 setmapflag(msgscr, mSECRET);
20366 return true;
20367 }
20368 case MSGC_TRIG_CMB_COPYCAT:
20369 {
20370 int copy_id = args[0];
20371 if(copy_id == byte(copy_id))
20372 trig_copycat(copy_id);
20373 return true;
20374 }
20375 case MSGC_SETSCREENSTATE:
20376 {
20377 int32_t flag = args[0];
20378 if(unsigned(flag)>=mMAXIND)
20379 {
20380 Z_error("SCC 133: Flag %d is invalid\n", flag);
20381 return true;
20382 }
20383 bool state = args[1];
20384 if(state)
20385 setmapflag(msgscr, 1<<flag);
20386 else
20387 unsetmapflag(msgscr, 1<<flag, true);
20388 return true;
20389 }
20390 case MSGC_SETSCREENSTATER:
20391 {
20392 int32_t map = args[0];
20393 int32_t scrid = args[1];
20394 if(map < 1 || map > map_count)
20395 {
20396 Z_error("SCC 134: Map %d is invalid\n", map);
20397 return true;
20398 }
20399 if(unsigned(scrid)>=0x80)
20400 {
20401 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20402 return true;
20403 }
20404
20405 int32_t flag = args[2];
20406 if(unsigned(flag)>=mMAXIND)
20407 {
20408 Z_error("SCC 134: Flag %d is invalid\n", flag);
20409 return true;
20410 }
20411 bool state = args[3];
20412 if(state)
20413 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20414 else
20415 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20416 return true;
20417 }
20418 switched:
20419 55 int32_t lev = args[last_arg];
20420
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20421
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20422 {
20423 setmsg(lev);
20424 }
20425 else
20426 {
20427 55 donewmsg(msgscr, lev);
20428 55 ssc_tile_hei_buf = -1;
20429 }
20430 55 putprices(false);
20431 55 return true;
20432 }
20433
20434 return false;
20435 3713 }
20436
20437 3719 static std::string parsemsgcode2(const StringCommand& command)
20438 {
20439
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 6 times.
3719 if (command.code == MSGC_NAME)
20440 {
20441
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20442 }
20443 else
20444 {
20445 3713 parsemsgcode(command);
20446 }
20447
20448
1/2
✓ Branch 0 taken 3713 times.
✗ Branch 1 not taken.
3713 return "";
20449 3719 }
20450
20451 292399 static bool putmsgchar(bool play_sfx)
20452 {
20453 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20454 DCHECK(!msg_it->character.empty());
20455
20456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292399 times.
292399 if (bottom_margin_clip())
20457 return false;
20458
20459 // If the current word would overflow the margins, increment cursor to the next line.
20460 292399 const char* rem_word = msg_it->remaining_word();
20461 292399 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20462
4/4
✓ Branch 0 taken 6441 times.
✓ Branch 1 taken 285958 times.
✓ Branch 2 taken 1147 times.
✓ Branch 3 taken 5087 times.
298633 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20463
4/4
✓ Branch 0 taken 6234 times.
✓ Branch 1 taken 207 times.
✓ Branch 2 taken 5087 times.
✓ Branch 3 taken 207 times.
6441 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20464 {
20465 6234 ssc_tile_hei = ssc_tile_hei_buf;
20466
1/2
✓ Branch 0 taken 6234 times.
✗ Branch 1 not taken.
6234 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20467 6234 ssc_tile_hei_buf = -1;
20468 6234 cursor_y += thei + MsgStrings[msgstr].vspace;
20469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6234 times.
6234 if (bottom_margin_clip()) return false;
20470
20471 6234 cursor_x = msg_margins[left];
20472 6234 }
20473
20474
2/2
✓ Branch 0 taken 40241 times.
✓ Branch 1 taken 252158 times.
292399 if (play_sfx)
20475 252158 sfx(MsgStrings[msgstr].sfx);
20476
20477 // Print the character (unless it's just a space).
20478
2/2
✓ Branch 0 taken 66569 times.
✓ Branch 1 taken 225830 times.
292399 if (msg_it->character != " ")
20479 225830 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20480
20481 // Move the cursor.
20482 292399 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20483
2/2
✓ Branch 0 taken 66569 times.
✓ Branch 1 taken 225830 times.
292399 if (msg_it->character != " ")
20484 225830 cursor_x += MsgStrings[msgstr].hspace;
20485
20486 292399 return true;
20487 292399 }
20488
20489 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20490
20491 static void msg_tick_end(bool disappear = false);
20492 281178 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20493 {
20494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281178 times.
281178 if (msg_it->done())
20495 return msg_tick_exit;
20496
20497
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 279147 times.
281178 if (!do_run_menu)
20498 {
20499
4/4
✓ Branch 0 taken 279147 times.
✓ Branch 1 taken 3719 times.
✓ Branch 2 taken 279147 times.
✓ Branch 3 taken 3719 times.
282866 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20500 {
20501 3719 bool one_frame_command_delay = !replay_version_check(41);
20502 3719 std::string text = parsemsgcode2(msg_it->command);
20503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3719 times.
3719 if (wait_advance)
20504 break;
20505
20506
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 6 times.
3719 if (text.empty())
20507 {
20508
2/4
✓ Branch 0 taken 3713 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3713 times.
✗ Branch 3 not taken.
3713 msg_it->set_buffer("");
20509 // Advance the iterator to run many commands in one frame.
20510
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 3169 times.
3713 if (!one_frame_command_delay)
20511
1/2
✓ Branch 0 taken 544 times.
✗ Branch 1 not taken.
544 msg_it->next();
20512 3713 }
20513 else
20514 {
20515
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20516
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20518 6 msg_it->post_segment_delay = 1;
20519 }
20520
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3719 times.
3719 }
20521
20522
2/2
✓ Branch 0 taken 3195 times.
✓ Branch 1 taken 275952 times.
279147 if (msg_it->state == MsgStr::iterator::CHARACTER)
20523 {
20524
1/2
✓ Branch 0 taken 275952 times.
✗ Branch 1 not taken.
275952 if (!putmsgchar(play_sfx)) return msg_tick_break;
20525 275952 }
20526 279147 }
20527
20528 281178 bool wait_advance_check_early = !burst_mode;
20529
20530
2/2
✓ Branch 0 taken 105478 times.
✓ Branch 1 taken 175700 times.
281178 if (wait_advance_check_early)
20531 {
20532
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 175699 times.
175700 if (do_end_str)
20533 {
20534 1 msg_tick_end();
20535 1 return msg_tick_exit;
20536 }
20537
20538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175699 times.
175699 if (wait_advance)
20539 {
20540 msg_it->next();
20541 return msg_tick_exit;
20542 }
20543 175699 }
20544
20545
2/2
✓ Branch 0 taken 279141 times.
✓ Branch 1 taken 2036 times.
281177 if (do_run_menu)
20546 {
20547
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20548 {
20549 5 do_run_menu = false;
20550
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20551 {
20552 2 msg_it->next();
20553 2 return msg_tick(play_sfx, burst_mode);
20554 }
20555 3 }
20556 2031 else return msg_tick_break;
20557 3 }
20558
20559 279144 msg_it->next();
20560
20561
2/2
✓ Branch 0 taken 174200 times.
✓ Branch 1 taken 104944 times.
279144 if (!wait_advance_check_early)
20562 {
20563
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 104942 times.
104944 if (do_end_str)
20564 {
20565 2 msg_tick_end();
20566 2 return msg_tick_exit;
20567 }
20568
20569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104942 times.
104942 if (wait_advance)
20570 return msg_tick_exit;
20571 104942 }
20572
20573
4/4
✓ Branch 0 taken 4375 times.
✓ Branch 1 taken 274767 times.
✓ Branch 2 taken 2119 times.
✓ Branch 3 taken 2256 times.
279142 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20574 {
20575
1/2
✓ Branch 0 taken 2119 times.
✗ Branch 1 not taken.
2119 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20576 setmsg(MsgStrings[msgstr].nextstring);
20577 2119 }
20578
20579 279142 return msg_tick_continue;
20580 281178 }
20581
20582 178538 static void msg_tick_end(bool disappear)
20583 {
20584
2/2
✓ Branch 0 taken 177259 times.
✓ Branch 1 taken 1279 times.
178538 if (disappear)
20585 1279 goto disappear;
20586
20587 // Done printing the string
20588
8/8
✓ Branch 0 taken 177256 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 175759 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 171365 times.
✓ Branch 5 taken 4394 times.
✓ Branch 6 taken 171365 times.
✓ Branch 7 taken 4394 times.
177259 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20589 {
20590
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4394 times.
4397 if(!do_end_str)
20591 {
20592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4394 times.
4394 while (msg_it->state == MsgStr::iterator::COMMAND)
20593 {
20594 parsemsgcode2(msg_it->command);
20595 msg_it->next();
20596 }
20597 4394 }
20598
20599 // Go to next string, or make it disappear by going to string 0.
20600
5/6
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 2121 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4397 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20601 {
20602 3401 linkedmsgclk=do_end_str?1:51;
20603 3401 }
20604
20605
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 2121 times.
4397 if(MsgStrings[msgstr].nextstring==0)
20606 {
20607
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 996 times.
2276 if(!get_qr(qr_MSGDISAPPEAR))
20608 996 {
20609 disappear:
20610 2275 msg_active = false;
20611 2275 Hero.finishedmsg();
20612 2275 }
20613
20614
2/2
✓ Branch 0 taken 3542 times.
✓ Branch 1 taken 13 times.
3555 if(repaircharge)
20615 {
20616
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20617 13 repaircharge = 0;
20618 13 }
20619
20620
2/2
✓ Branch 0 taken 3553 times.
✓ Branch 1 taken 2 times.
3555 if(adjustmagic)
20621 {
20622
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20623 {
20624
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20625 2 game->set_magicdrainrate(1);
20626 2 }
20627 else if(game->get_magicdrainrate() > 1)
20628 {
20629 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20630 }
20631 2 adjustmagic = false;
20632 2 sfx(WAV_SCALE);
20633
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20634 2 }
20635
20636
2/2
✓ Branch 0 taken 3553 times.
✓ Branch 1 taken 2 times.
3555 if(learnslash)
20637 {
20638 2 game->set_canslash(1);
20639 2 learnslash = false;
20640 2 sfx(WAV_SCALE);
20641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20642 2 }
20643 3555 }
20644 5676 }
20645 178538 }
20646
20647 6604 static void msg_consume_spaces()
20648 {
20649
2/2
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 16447 times.
23051 while (msg_it->character == " ")
20650 {
20651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16447 times.
16447 if (!putmsgchar(false)) break;
20652
20653 // Advance the iterator.
20654 16447 msg_it->next();
20655
20656 // The "Continue From Previous" feature
20657
1/2
✓ Branch 0 taken 16447 times.
✗ Branch 1 not taken.
16447 if (msg_it->state == MsgStr::iterator::DONE)
20658 {
20659 if(MsgStrings[msgstr].nextstring)
20660 {
20661 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20662 {
20663 setmsg(MsgStrings[msgstr].nextstring);
20664 }
20665 }
20666 }
20667 }
20668 6604 }
20669
20670 15193715 void putmsg()
20671 {
20672
2/2
✓ Branch 0 taken 731338 times.
✓ Branch 1 taken 14462377 times.
15193715 if(!msgorig) msgorig=msgstr;
20673
20674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15193715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15193715 if(wait_advance && linkedmsgclk < 1)
20675 linkedmsgclk = 1;
20676
2/2
✓ Branch 0 taken 14881348 times.
✓ Branch 1 taken 312367 times.
15193715 if(linkedmsgclk>0)
20677 {
20678
2/2
✓ Branch 0 taken 142516 times.
✓ Branch 1 taken 169851 times.
312367 if(linkedmsgclk==1)
20679 {
20680
6/6
✓ Branch 0 taken 142513 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 139253 times.
✓ Branch 3 taken 3260 times.
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 139117 times.
142516 if(do_end_str||cAbtn()||cBbtn())
20681 {
20682 3399 do_end_str = false;
20683 3399 linkedmsgclk = 0;
20684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3399 times.
3399 if(wait_advance)
20685 {
20686 wait_advance = false;
20687 }
20688 else
20689 {
20690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3399 times.
3399 if (!msgscr) msgscr = hero_scr;
20691 3399 msgstr=MsgStrings[msgstr].nextstring;
20692 3399 ssc_tile_hei_buf = -1;
20693
3/4
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 2120 times.
✓ Branch 2 taken 1279 times.
✗ Branch 3 not taken.
3399 if(!msgstr && enqueued_str)
20694 {
20695 msgstr = enqueued_str;
20696 enqueued_str = 0;
20697 }
20698
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 2120 times.
3399 if(!msgstr)
20699 {
20700 1279 msgfont=get_zc_font(font_zfont);
20701
20702
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1275 times.
1279 if(msgscr->room!=rGRUMBLE)
20703 1275 blockpath=false;
20704
20705 1279 dismissmsg();
20706 1279 msg_tick_end(true);
20707 1279 return;
20708 }
20709
20710 2120 donewmsg(msgscr, msgstr);
20711 2120 putprices(false);
20712 }
20713 2120 }
20714 141237 }
20715 else
20716 {
20717 169851 --linkedmsgclk;
20718 }
20719 311088 }
20720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15192436 times.
15192436 if(wait_advance) return; //Waiting for buttonpress
20721
20722
9/10
✓ Branch 0 taken 15190503 times.
✓ Branch 1 taken 1933 times.
✓ Branch 2 taken 725910 times.
✓ Branch 3 taken 14464593 times.
✓ Branch 4 taken 279121 times.
✓ Branch 5 taken 446789 times.
✓ Branch 6 taken 274728 times.
✓ Branch 7 taken 4393 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 274728 times.
15192436 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20723 {
20724
2/2
✓ Branch 0 taken 14464593 times.
✓ Branch 1 taken 451182 times.
14915775 if(!msgstr)
20725 14464593 msgorig=0;
20726
20727 14915775 msg_active = false;
20728 14915775 msg_it.reset();
20729 14915775 return;
20730 }
20731
20732
1/2
✓ Branch 0 taken 276661 times.
✗ Branch 1 not taken.
276661 if (!msg_it)
20733 return;
20734
20735 276661 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20736
20737
2/2
✓ Branch 0 taken 272244 times.
✓ Branch 1 taken 4417 times.
276661 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20738 {
20739 4417 msg_it->next();
20740 4417 msg_consume_spaces();
20741 4417 }
20742
20743 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20744 // as possible. This skips the character-by-character animation that usually renders a string
20745 // slowly over many frames.
20746
4/4
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 274995 times.
✓ Branch 2 taken 875 times.
✓ Branch 3 taken 274120 times.
276661 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20747 {
20748
2/2
✓ Branch 0 taken 1559 times.
✓ Branch 1 taken 105488 times.
107483 while (!msg_it->done())
20749 {
20750
5/6
✓ Branch 0 taken 47643 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 47633 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 47633 times.
✗ Branch 5 not taken.
105488 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20751 10 goto breakout; // break out if message speed was changed to non-zero
20752
20753 105478 auto tick = msg_tick(msg_it->character != " ", true);
20754
2/2
✓ Branch 0 taken 104944 times.
✓ Branch 1 taken 534 times.
105478 if (tick == msg_tick_break)
20755 534 break;
20756
2/2
✓ Branch 0 taken 104942 times.
✓ Branch 1 taken 2 times.
104944 if (tick == msg_tick_exit)
20757 2 return;
20758 }
20759
20760
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1559 times.
2093 if (!do_run_menu)
20761 {
20762 1559 msgclk = 72;
20763 1559 }
20764 2093 }
20765 else
20766 274120 {
20767 breakout:
20768 274130 word tempspeed = msgspeed;
20769
2/2
✓ Branch 0 taken 273167 times.
✓ Branch 1 taken 963 times.
274130 if (do_run_menu)
20770 963 tempspeed = 0;
20771
6/6
✓ Branch 0 taken 215441 times.
✓ Branch 1 taken 58689 times.
✓ Branch 2 taken 126552 times.
✓ Branch 3 taken 88889 times.
✓ Branch 4 taken 116475 times.
✓ Branch 5 taken 10077 times.
274130 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20772 98966 return;
20773 }
20774
20775 // Process the next msg tick.
20776 // This will either print a single character, or process a single string command (with one
20777 // exception).
20778
3/4
✓ Branch 0 taken 175698 times.
✓ Branch 1 taken 1559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175698 times.
177257 if (!msg_it->done() && !bottom_margin_clip())
20779 {
20780 // This may run an additional tick in the case of a string menu finishing: the first
20781 // tick wraps up the menu, and then a second tick processes the next character or command.
20782 175698 auto tick = msg_tick(true, false);
20783
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 174201 times.
175698 if (tick == msg_tick_break)
20784 {
20785 1497 msg_tick_end();
20786 1497 return;
20787 }
20788
2/2
✓ Branch 0 taken 174200 times.
✓ Branch 1 taken 1 times.
174201 if (tick == msg_tick_exit)
20789 1 return;
20790
20791 // If the next two characters are spaces, consume all upcoming spaces now.
20792
13/20
✓ Branch 0 taken 2835 times.
✓ Branch 1 taken 171365 times.
✓ Branch 2 taken 171365 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28480 times.
✓ Branch 5 taken 142885 times.
✓ Branch 6 taken 28480 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 28480 times.
✓ Branch 10 taken 145720 times.
✓ Branch 11 taken 28480 times.
✓ Branch 12 taken 2835 times.
✓ Branch 13 taken 171365 times.
✓ Branch 14 taken 172013 times.
✓ Branch 15 taken 2187 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
202680 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20793 2187 msg_consume_spaces();
20794 174200 }
20795
20796 175759 msg_tick_end();
20797 15193279 }
20798
20799 140521 int32_t message_more_y()
20800 {
20801 //Is the flag ticked, do we really want a message more y larger than 160?
20802
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 140493 times.
✓ Branch 2 taken 140521 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140493 times.
✓ Branch 5 taken 28 times.
140521 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20803 140521 msgy+=playing_field_offset;
20804 140521 return msgy;
20805 }
20806
20807 /*** Collision detection & handling ***/
20808
20809 14832670 void clear_script_one_frame_conditions()
20810 {
20811
2/2
✓ Branch 0 taken 40035761 times.
✓ Branch 1 taken 14832670 times.
54868431 for(int32_t j=0; j<guys.Count(); j++)
20812 {
20813 40035761 enemy *e = (enemy*)guys.spr(j);
20814
2/2
✓ Branch 0 taken 680607937 times.
✓ Branch 1 taken 40035761 times.
720643698 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20815 40035761 }
20816 14832670 }
20817
20818 6332453 void check_enemy_lweapon_collision(weapon *w)
20819 {
20820
8/8
✓ Branch 0 taken 5631760 times.
✓ Branch 1 taken 700693 times.
✓ Branch 2 taken 4578754 times.
✓ Branch 3 taken 1053006 times.
✓ Branch 4 taken 4511180 times.
✓ Branch 5 taken 67574 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 4494442 times.
6332453 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20821 {
20822
2/2
✓ Branch 0 taken 4478385 times.
✓ Branch 1 taken 14286019 times.
18764404 for(int32_t j=0; j<guys.Count(); j++)
20823 {
20824 14286019 enemy *e = (enemy*)guys.spr(j);
20825
20826 14286019 bool didhit = e->hit(w);
20827 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20828 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20829
2/2
✓ Branch 0 taken 14057767 times.
✓ Branch 1 taken 228252 times.
14286019 if(didhit)
20830 {
20831 // !(e->stunclk)
20832 228252 int32_t h = e->takehit(w);
20833
2/2
✓ Branch 0 taken 193222 times.
✓ Branch 1 taken 35030 times.
228252 if (h < 0) // hitby code
20834 {
20835 35030 int indx = Lwpns.find(w);
20836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35030 times.
35030 if(indx > -1)
20837 35030 e->hitby[HIT_BY_LWEAPON] = indx+1;
20838 35030 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20839 35030 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20840
2/2
✓ Branch 0 taken 32565 times.
✓ Branch 1 taken 2465 times.
35030 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
20841 2465 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20842 35030 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20843 35030 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20844 //we may need to handle this in special cases. -Z
20845 // arrow item pierce flag, for example -Em
20846 35030 }
20847
20848
2/2
✓ Branch 0 taken 35030 times.
✓ Branch 1 taken 193222 times.
228252 if(h < 0) // hit, check if weapon is "out of pierces"
20849 35030 w->hit_pierce(e, h);
20850
2/2
✓ Branch 0 taken 182588 times.
✓ Branch 1 taken 10634 times.
193222 else if(h > 0) // blocked
20851 10634 w->onhit(false, e, h);
20852
2/2
✓ Branch 0 taken 225578 times.
✓ Branch 1 taken 2674 times.
228252 if(abs(h) == 2)
20853 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
20854 225578 }
20855
20856
2/2
✓ Branch 0 taken 14269962 times.
✓ Branch 1 taken 13383 times.
14283345 if(w->Dead())
20857 {
20858 13383 break;
20859 }
20860 14269962 }
20861
20862 // Item flags added in 2.55:
20863 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20864 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20865 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20866 // -Em
20867
6/6
✓ Branch 0 taken 4031962 times.
✓ Branch 1 taken 462480 times.
✓ Branch 2 taken 3987048 times.
✓ Branch 3 taken 44914 times.
✓ Branch 4 taken 58271 times.
✓ Branch 5 taken 3928777 times.
4494442 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20868 {
20869 565665 int32_t itype, pitem = w->parentitem;
20870
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 462480 times.
✓ Branch 2 taken 58271 times.
✓ Branch 3 taken 44914 times.
565665 switch(w->id)
20871 {
20872 462480 case wBrang: itype = itype_brang; break;
20873 58271 case wArrow: itype = itype_arrow; break;
20874 case wHookshot:
20875 44914 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20876 44914 break;
20877 }
20878
2/2
✓ Branch 0 taken 550738 times.
✓ Branch 1 taken 14927 times.
565665 if(pitem < 0) pitem = current_item_id(itype);
20879
5/6
✓ Branch 0 taken 44914 times.
✓ Branch 1 taken 520751 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44814 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
565665 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20880 { //Swap with item
20881 for(int32_t j=0; j<items.Count(); j++)
20882 {
20883 if(items.spr(j)->hit(w))
20884 {
20885 item *theItem = ((item*)items.spr(j));
20886 bool priced = theItem->PriceIndex >-1;
20887 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20888 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20889 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20890 {
20891 if(!Hero.switchhookclk)
20892 {
20893 hooked_comborpos = rpos_t::None;
20894 hooked_layerbits = 0;
20895 switching_object = theItem;
20896 theItem->switch_hooked = true;
20897 w->misc = 2;
20898 w->step = 0;
20899 theItem->clk2 = game->get_item_timeout_dur() / 2;
20900 Hero.doSwitchHook(game->get_switchhookstyle());
20901 if(QMisc.miscsfx[sfxSWITCHED])
20902 sfx(QMisc.miscsfx[sfxSWITCHED],pan(w->x));
20903 }
20904 }
20905 }
20906 }
20907 }
20908
6/6
✓ Branch 0 taken 58271 times.
✓ Branch 1 taken 507394 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 316668 times.
✓ Branch 4 taken 507394 times.
✓ Branch 5 taken 316668 times.
565665 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20909 {
20910
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
20911 {
20912
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
20913 {
20914 4898 item *theItem = ((item*)items.spr(j));
20915 4898 bool priced = theItem->PriceIndex >-1;
20916
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20917
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20918
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20919 {
20920
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
20921 {
20922 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20923 }
20924
20925 1724 Hero.checkitems(j);
20926 1724 }
20927 4898 }
20928 88886 }
20929 374939 }
20930
2/2
✓ Branch 0 taken 29180 times.
✓ Branch 1 taken 161546 times.
824062 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20931 {
20932
2/2
✓ Branch 0 taken 38285 times.
✓ Branch 1 taken 161546 times.
199831 for(int32_t j=0; j<items.Count(); j++)
20933 {
20934
2/2
✓ Branch 0 taken 29347 times.
✓ Branch 1 taken 8938 times.
38285 if(items.spr(j)->hit(w))
20935 {
20936 8938 item *theItem = ((item*)items.spr(j));
20937 8938 bool priced = theItem->PriceIndex >-1;
20938
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8931 times.
8938 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20939
4/6
✓ Branch 0 taken 8938 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8655 times.
✓ Branch 5 taken 283 times.
8938 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
20940
5/10
✓ Branch 0 taken 7455 times.
✓ Branch 1 taken 1200 times.
✓ Branch 2 taken 1483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1483 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1483 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8938 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20941 {
20942 7455 int32_t pickup = theItem->pickup;
20943 7455 int32_t id2 = theItem->id;
20944 7455 int32_t pstr = theItem->pstring;
20945 7455 int32_t pstr_flags = theItem->pickup_string_flags;
20946
20947 7455 std::vector<int32_t> &ev = FFCore.eventData;
20948 7455 ev.clear();
20949 7455 ev.push_back(id2*10000);
20950 7455 ev.push_back(pickup*10000);
20951 7455 ev.push_back(pstr*10000);
20952 7455 ev.push_back(pstr_flags*10000);
20953 7455 ev.push_back(0);
20954 7455 ev.push_back(theItem->getUID());
20955 7455 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20956 7455 ev.push_back(w->getUID());
20957
20958 7455 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20959 7455 bool nullify = ev[4] != 0;
20960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7455 times.
7455 if(nullify) continue;
20961
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6379 times.
7455 if(w->id == wBrang)
20962 {
20963 6379 w->onhit(false);
20964 6379 }
20965
20966
2/2
✓ Branch 0 taken 6951 times.
✓ Branch 1 taken 504 times.
7455 if(w->dragging==-1)
20967 {
20968 504 w->dead=1;
20969 504 theItem->clk2 = game->get_item_timeout_dur() / 2;
20970 504 w->dragging=j;
20971 504 theItem->is_dragged = true;
20972 504 }
20973 7455 }
20974 8938 }
20975 38285 }
20976 161546 }
20977 565665 }
20978 4494442 }
20979 6332453 }
20980 14830467 void check_collisions()
20981 {
20982
2/2
✓ Branch 0 taken 6332418 times.
✓ Branch 1 taken 14830467 times.
21162885 for(uint q = 0; q < Lwpns.Count(); ++q)
20983 6332418 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20984 14830467 }
20985
20986 14832670 void dragging_item()
20987 {
20988
2/2
✓ Branch 0 taken 6531126 times.
✓ Branch 1 taken 14832670 times.
21363796 for(int32_t i=0; i<Lwpns.Count(); i++)
20989 {
20990 6531126 weapon *w = (weapon*)Lwpns.spr(i);
20991
20992
4/4
✓ Branch 0 taken 6059972 times.
✓ Branch 1 taken 471154 times.
✓ Branch 2 taken 6367520 times.
✓ Branch 3 taken 163606 times.
6531126 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
20993 {
20994
3/4
✓ Branch 0 taken 7429 times.
✓ Branch 1 taken 156177 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7429 times.
163606 if(w->dragging>=0 && w->dragging<items.Count())
20995 {
20996 7429 item* dragItem = (item*)items.spr(w->dragging);
20997 7429 dragItem->x=w->x;
20998 7429 dragItem->y=w->y;
20999
21000 // Drag the Fairy enemy as well as the Fairy item
21001 7429 int32_t id = dragItem->id;
21002
21003
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 7010 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7429 if(itemsbuf[id].type ==itype_fairy && itemsbuf[id].misc3)
21004 {
21005 404 movefairynew2(w->x,w->y,*dragItem);
21006 404 }
21007 7429 }
21008 163606 }
21009 6531126 }
21010 14832670 }
21011
21012 64 int32_t more_carried_items(int screen)
21013 {
21014 64 int32_t hasmorecarries = 0;
21015
21016
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 64 times.
135 for(int32_t i=0; i<items.Count(); i++)
21017 {
21018 71 auto spr = (item*)items.spr(i);
21019
4/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 64 times.
71 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21020 {
21021 64 hasmorecarries++;
21022 64 }
21023 71 }
21024
21025 64 return hasmorecarries;
21026 }
21027
21028 43413 static int count_guys_from_screen(int screen)
21029 {
21030 43413 int count = 0;
21031
2/2
✓ Branch 0 taken 244979 times.
✓ Branch 1 taken 43413 times.
288392 for (int i=0; i < guys.Count(); i++)
21032 {
21033
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 208441 times.
244979 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21034 208441 count += 1;
21035 244979 }
21036 43413 return count;
21037 }
21038
21039 // messy code to do the enemy-carrying-the-item thing
21040 15220598 static void roaming_item(mapscr* scr)
21041 {
21042 15220598 int screen = scr->screen;
21043 15220598 auto& state = get_screen_state(screen);
21044
4/4
✓ Branch 0 taken 15177254 times.
✓ Branch 1 taken 43344 times.
✓ Branch 2 taken 15177185 times.
✓ Branch 3 taken 43413 times.
15220598 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21045 15177185 return;
21046
21047 // All enemies already dead upon entering a room?
21048
1/2
✓ Branch 0 taken 43413 times.
✗ Branch 1 not taken.
43413 if (count_guys_from_screen(screen) == 0)
21049 {
21050 return;
21051 }
21052
21053 43413 int guycarryingitem = -1;
21054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91422 times.
91422 for(int32_t j=0; j<guys.Count(); j++)
21055 {
21056 91422 enemy* e = (enemy*)guys.spr(j);
21057
4/4
✓ Branch 0 taken 69728 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 43413 times.
91422 if (e->screen_spawned == screen && e->itemguy)
21058 {
21059 43413 guycarryingitem=j;
21060 43413 break;
21061 }
21062 48009 }
21063
21064
2/2
✓ Branch 0 taken 43329 times.
✓ Branch 1 taken 84 times.
43413 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21065 {
21066
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(guycarryingitem == -1) //This happens when "default enemies" such as
21067 {
21068 return; //eSHOOTFBALL are alive but enemies from the list
21069 } //are not. Defer to HeroClass::checkspecial().
21070
21071 84 int32_t Item=scr->item;
21072
21073 84 state.item_state = ScreenItemState::None;
21074
21075
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
84 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21076 {
21077 168 auto [x, y] = translate_screen_coordinates_to_world(screen);
21078 236 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21079
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 16 times.
84 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].type==itype_triforcepiece)) ? ipHOLDUP : 0)
21080 );
21081 84 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21082 84 state.item_state = ScreenItemState::CarriedByEnemy;
21083 84 }
21084 else
21085 {
21086 return;
21087 }
21088 84 }
21089
21090
2/2
✓ Branch 0 taken 52922 times.
✓ Branch 1 taken 43413 times.
96335 for(int32_t i=0; i<items.Count(); i++)
21091 {
21092
4/4
✓ Branch 0 taken 49311 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 43413 times.
52922 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21093 {
21094
2/2
✓ Branch 0 taken 29118 times.
✓ Branch 1 taken 14295 times.
43413 if(get_qr(qr_HIDECARRIEDITEMS))
21095 {
21096 29118 items.spr(i)->x = -128; // Awfully inelegant, innit?
21097 29118 items.spr(i)->y = -128;
21098 29118 }
21099
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21100 {
21101
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21102 {
21103 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21104 {
21105 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21106 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21107 }
21108 else
21109 {
21110 if(guys.spr(guycarryingitem)->extend >= 3)
21111 {
21112 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21113 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21114 }
21115 else
21116 {
21117 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21118 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21119 }
21120 }
21121 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21122 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21123 }
21124 else
21125 {
21126 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21127 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21128 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21129 }
21130 14295 }
21131 43413 }
21132 52922 }
21133 15220598 }
21134
21135 14832670 void roaming_item()
21136 {
21137 30053268 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21138 15220598 roaming_item(scr);
21139 15220598 });
21140 14832670 }
21141
21142 bool enemy::IsBigAnim()
21143 {
21144 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21145 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21146 || anim == a4FRM8DIRB);
21147 }
21148 2490371 int32_t enemy::getFlashingCSet()
21149 {
21150 //Special cset for the dying sprite
21151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2490371 times.
2490371 if(dying)
21152 {
21153 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21154 return wpnsbuf[spr_death].csets & 15;
21155 else
21156 return (((clk2 + 5) >> 1) & 3) + 6;
21157 }
21158
21159 //Normal cset
21160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2490371 times.
2490371 if (hclk <= 0)
21161 {
21162 //Special cset for the flashing animation
21163 if (flags & guy_flashing)
21164 return (frame & 3) + 6;
21165 return cs;
21166 }
21167
21168 //Hurt animations
21169
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2486483 times.
2490371 if(type==eeGANON)
21170 3888 return (((hclk-1)>>1)&3)+6;
21171
4/4
✓ Branch 0 taken 2312359 times.
✓ Branch 1 taken 174124 times.
✓ Branch 2 taken 554477 times.
✓ Branch 3 taken 1757882 times.
2486483 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21172 1757882 return (((hclk-1)>>1)&3)+6;
21173
21174 728601 return cs;
21175 2490371 }
21176
21177 83395497 bool enemy::is_hitflickerframe(bool olddrawing)
21178 {
21179
6/6
✓ Branch 0 taken 83366993 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 4085526 times.
✓ Branch 3 taken 79281467 times.
✓ Branch 4 taken 3199831 times.
✓ Branch 5 taken 885695 times.
83395497 if (type == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21180 82509802 return false;
21181
21182
3/4
✓ Branch 0 taken 609055 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 609055 times.
✗ Branch 3 not taken.
885695 if (!olddrawing && !getCanFlicker())
21183 return false;
21184
21185 885695 int32_t fr = game->get_spriteflickerspeed();
21186
1/2
✓ Branch 0 taken 885695 times.
✗ Branch 1 not taken.
885695 if (fr == 0)
21187 return true;
21188 885695 return frame % (fr * 2) < fr;
21189 83395497 }
21190
21191 const char *old_guy_string[OLDMAXGUYS] =
21192 {
21193 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21194 // 020
21195 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21196 // 025
21197 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21198 // 030
21199 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21200 // 035
21201 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21202 // 040
21203 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21204 // 045
21205 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21206 // 050
21207 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21208 // 055
21209 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21210 // 060
21211 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21212 // 065
21213 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21214 // 070
21215 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21216 // 075
21217 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21218 // 080
21219 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21220 // 085
21221 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21222 // 090
21223 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21224 // 095
21225 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21226 // 100
21227 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21228 // 105
21229 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21230 // 110
21231 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21232 // 115
21233 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21234 // 120
21235 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21236 // 125
21237 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21238 // 130
21239 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21240 // 135
21241 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21242 // 140
21243 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21244 // 145
21245 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21246 // 150
21247 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21248 // 155
21249 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21250 // 160
21251 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21252 // 165
21253 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21254 // 170
21255 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21256 // 175
21257 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21258 };
21259
21260 16717110 int32_t enemy::get_dmisc(byte index)
21261 {
21262
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 18181 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1799 times.
✓ Branch 6 taken 1056 times.
✓ Branch 7 taken 255 times.
✓ Branch 8 taken 1857 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 8820348 times.
✓ Branch 11 taken 7597396 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
16717110 switch (index)
21263 {
21264 14611 case 0: return dmisc1;
21265 18181 case 1: return dmisc2;
21266 3236 case 2: return dmisc3;
21267 7390 case 3: return dmisc4;
21268 2144 case 4: return dmisc5;
21269 1799 case 5: return dmisc6;
21270 1056 case 6: return dmisc7;
21271 255 case 7: return dmisc8;
21272 1857 case 8: return dmisc9;
21273 1822 case 9: return dmisc10;
21274 8820348 case 10: return dmisc11;
21275 7597396 case 11: return dmisc12;
21276 case 12: return dmisc13;
21277 308 case 13: return dmisc14;
21278 case 14: return dmisc15;
21279 40 case 15: return dmisc16;
21280 case 16: return dmisc17;
21281 216 case 17: return dmisc18;
21282 case 18: return dmisc19;
21283 case 19: return dmisc20;
21284 case 20: return dmisc21;
21285 case 21: return dmisc22;
21286 case 22: return dmisc23;
21287 case 23: return dmisc24;
21288 884 case 24: return dmisc25;
21289 1120 case 25: return dmisc26;
21290 331 case 26: return dmisc27;
21291 238061 case 27: return dmisc28;
21292 case 28: return dmisc29;
21293 case 29: return dmisc30;
21294 case 30: return dmisc31;
21295 6055 case 31: return dmisc32;
21296 }
21297
21298 return 0;
21299 16717110 }
21300
21301 312 void enemy::set_dmisc(byte index, int32_t value)
21302 {
21303
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21304 {
21305 case 0: dmisc1 = value; break;
21306 case 1: dmisc2 = value; break;
21307 case 2: dmisc3 = value; break;
21308 case 3: dmisc4 = value; break;
21309 case 4: dmisc5 = value; break;
21310 case 5: dmisc6 = value; break;
21311 case 6: dmisc7 = value; break;
21312 case 7: dmisc8 = value; break;
21313 case 8: dmisc9 = value; break;
21314 case 9: dmisc10 = value; break;
21315 case 10: dmisc11 = value; break;
21316 case 11: dmisc12 = value; break;
21317 case 12: dmisc13 = value; break;
21318 case 13: dmisc14 = value; break;
21319 case 14: dmisc15 = value; break;
21320 case 15: dmisc16 = value; break;
21321 case 16: dmisc17 = value; break;
21322 case 17: dmisc18 = value; break;
21323 case 18: dmisc19 = value; break;
21324 case 19: dmisc20 = value; break;
21325 case 20: dmisc21 = value; break;
21326 case 21: dmisc22 = value; break;
21327 case 22: dmisc23 = value; break;
21328 case 23: dmisc24 = value; break;
21329 case 24: dmisc25 = value; break;
21330 case 25: dmisc26 = value; break;
21331 4 case 26: dmisc27 = value; break;
21332 24 case 27: dmisc28 = value; break;
21333 case 28: dmisc28 = value; break;
21334 case 29: dmisc30 = value; break;
21335 case 30: dmisc31 = value; break;
21336 284 case 31: dmisc32 = value; break;
21337 }
21338 312 }
21339